With awk
:
$ awk '{ $1 -= lshift(rshift($1,16),16); print }' <file
39961 VE3THW Wayne
39962 VA3ECM Mathieu
39963 VE3QC Guy
39964 VE3LDY Louella
39965 VE3JFN Jeffrey
39966 VA3UZ Allan
39967 VA3BOC Hans
39968 VE3JMR
39969 VA3AMO Rolando
39970 VA3AMO Rolando
39973 VE3SLD Barry
39974 VA3DB Diane
39975 VE3FVD Friedrich
39976 VE3IAO John
39977 VA3MSV John
39978 VA3BTQ Jacqualine
39979 VA3BTQ Jacqualine
39980 VE3ZXN Denis
39981 VE3ZXN Denis
39982 VE3EM Don
39983 VA3TDG Douglas
39984 VA3MRJ David
39985 VA3ZDX Gregory
This removes everything but the lower 16 bits of information in the first column of the input data, which is what your script seems to be doing.
To more faithfully reproduce the tabular format of the input data, pipe the result through column -t
.
Using a shell loop:
while read -r num stuff; do
printf '%d %s\n' "$(( num - (( num >> 16 ) << 16) ))" "$stuff"
done <file
If you want the four second delay in printing each line, insert the appropriate sleep
calls in the shell loop or call system("sleep N")
in the awk
code, where N
is some positive number.
To use your original script:
while read -r num stuff; do
printf '%d %s\n' "$( ./bin.sh "$num" )" "$stuff"
done <file
That is, call the script in a command substitution with the number read from your file. Note though that this would be very inefficient on large files as your script calls several external utilities to do its calculation, and it additionally unconditionally clobbers a file (/tmp/bin.txt
) and leaves it behind. I would probably go with the awk
script myself.
Related: