Replace number in first column with out put of command for every line in file
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Hello all I am dealing with a ham hobby database file, example ;
DMRids.dat (section example) ;
1023001 VE3THW Wayne
1023002 VA3ECM Mathieu
1023003 VE3QC Guy
1023004 VE3LDY Louella
1023005 VE3JFN Jeffrey
1023006 VA3UZ Allan
1023007 VA3BOC Hans
1023008 VE3JMR
1023009 VA3AMO Rolando
1023010 VA3AMO Rolando
1023013 VE3SLD Barry
1023014 VA3DB Diane
1023015 VE3FVD Friedrich
1023016 VE3IAO John
1023017 VA3MSV John
1023018 VA3BTQ Jacqualine
1023019 VA3BTQ Jacqualine
1023020 VE3ZXN Denis
1023021 VE3ZXN Denis
1023022 VE3EM Don
1023023 VA3TDG Douglas
1023024 VA3MRJ David
1023025 VA3ZDX Gregory
For every first column number I want to replace the number with the result of being processed by this script ;
bin.sh
................................
!/bin/bash
cd /tmp
rm bin.txt
echo "obase=2;$1" | bc > bin.txt
sleep 2
value=cat bin.txt
sed -i 's/.*(................)/1/' bin.txt
sleep 2
echo "$((2#cat bin.txt
))"
.................................
example manual run for top line ;
root@vk4tux:/tmp# bin.sh 1023001
39961
root@vk4tux:/tmp#
So 1023001 would be replaced by 39961 and so on for each line in file individually treated to bin.sh input output replace. .
Any help much appreciated please?
linux sed scripting
New contributor
add a comment |Â
up vote
0
down vote
favorite
Hello all I am dealing with a ham hobby database file, example ;
DMRids.dat (section example) ;
1023001 VE3THW Wayne
1023002 VA3ECM Mathieu
1023003 VE3QC Guy
1023004 VE3LDY Louella
1023005 VE3JFN Jeffrey
1023006 VA3UZ Allan
1023007 VA3BOC Hans
1023008 VE3JMR
1023009 VA3AMO Rolando
1023010 VA3AMO Rolando
1023013 VE3SLD Barry
1023014 VA3DB Diane
1023015 VE3FVD Friedrich
1023016 VE3IAO John
1023017 VA3MSV John
1023018 VA3BTQ Jacqualine
1023019 VA3BTQ Jacqualine
1023020 VE3ZXN Denis
1023021 VE3ZXN Denis
1023022 VE3EM Don
1023023 VA3TDG Douglas
1023024 VA3MRJ David
1023025 VA3ZDX Gregory
For every first column number I want to replace the number with the result of being processed by this script ;
bin.sh
................................
!/bin/bash
cd /tmp
rm bin.txt
echo "obase=2;$1" | bc > bin.txt
sleep 2
value=cat bin.txt
sed -i 's/.*(................)/1/' bin.txt
sleep 2
echo "$((2#cat bin.txt
))"
.................................
example manual run for top line ;
root@vk4tux:/tmp# bin.sh 1023001
39961
root@vk4tux:/tmp#
So 1023001 would be replaced by 39961 and so on for each line in file individually treated to bin.sh input output replace. .
Any help much appreciated please?
linux sed scripting
New contributor
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Hello all I am dealing with a ham hobby database file, example ;
DMRids.dat (section example) ;
1023001 VE3THW Wayne
1023002 VA3ECM Mathieu
1023003 VE3QC Guy
1023004 VE3LDY Louella
1023005 VE3JFN Jeffrey
1023006 VA3UZ Allan
1023007 VA3BOC Hans
1023008 VE3JMR
1023009 VA3AMO Rolando
1023010 VA3AMO Rolando
1023013 VE3SLD Barry
1023014 VA3DB Diane
1023015 VE3FVD Friedrich
1023016 VE3IAO John
1023017 VA3MSV John
1023018 VA3BTQ Jacqualine
1023019 VA3BTQ Jacqualine
1023020 VE3ZXN Denis
1023021 VE3ZXN Denis
1023022 VE3EM Don
1023023 VA3TDG Douglas
1023024 VA3MRJ David
1023025 VA3ZDX Gregory
For every first column number I want to replace the number with the result of being processed by this script ;
bin.sh
................................
!/bin/bash
cd /tmp
rm bin.txt
echo "obase=2;$1" | bc > bin.txt
sleep 2
value=cat bin.txt
sed -i 's/.*(................)/1/' bin.txt
sleep 2
echo "$((2#cat bin.txt
))"
.................................
example manual run for top line ;
root@vk4tux:/tmp# bin.sh 1023001
39961
root@vk4tux:/tmp#
So 1023001 would be replaced by 39961 and so on for each line in file individually treated to bin.sh input output replace. .
Any help much appreciated please?
linux sed scripting
New contributor
Hello all I am dealing with a ham hobby database file, example ;
DMRids.dat (section example) ;
1023001 VE3THW Wayne
1023002 VA3ECM Mathieu
1023003 VE3QC Guy
1023004 VE3LDY Louella
1023005 VE3JFN Jeffrey
1023006 VA3UZ Allan
1023007 VA3BOC Hans
1023008 VE3JMR
1023009 VA3AMO Rolando
1023010 VA3AMO Rolando
1023013 VE3SLD Barry
1023014 VA3DB Diane
1023015 VE3FVD Friedrich
1023016 VE3IAO John
1023017 VA3MSV John
1023018 VA3BTQ Jacqualine
1023019 VA3BTQ Jacqualine
1023020 VE3ZXN Denis
1023021 VE3ZXN Denis
1023022 VE3EM Don
1023023 VA3TDG Douglas
1023024 VA3MRJ David
1023025 VA3ZDX Gregory
For every first column number I want to replace the number with the result of being processed by this script ;
bin.sh
................................
!/bin/bash
cd /tmp
rm bin.txt
echo "obase=2;$1" | bc > bin.txt
sleep 2
value=cat bin.txt
sed -i 's/.*(................)/1/' bin.txt
sleep 2
echo "$((2#cat bin.txt
))"
.................................
example manual run for top line ;
root@vk4tux:/tmp# bin.sh 1023001
39961
root@vk4tux:/tmp#
So 1023001 would be replaced by 39961 and so on for each line in file individually treated to bin.sh input output replace. .
Any help much appreciated please?
linux sed scripting
linux sed scripting
New contributor
New contributor
New contributor
asked 2 mins ago
Adrian Fewster
1
1
New contributor
New contributor
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Adrian Fewster is a new contributor. Be nice, and check out our Code of Conduct.
Adrian Fewster is a new contributor. Be nice, and check out our Code of Conduct.
Adrian Fewster is a new contributor. Be nice, and check out our Code of Conduct.
Adrian Fewster is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f477676%2freplace-number-in-first-column-with-out-put-of-command-for-every-line-in-file%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password