I have a file with lines like:
0 6 973 1346 2318 456 431 93 58 1 1 0 0 0 0
I want to extract the 1st, 4th and 5th number and save them in variables in bash for further use. In the example above the values I want are '0', '1346' and '2318'.
I am thinking to use sed but I dont know how. Any other ways are also welcome.
ps. Thanks for the answer, following is what I am using now:
for fn in $(cat filelist); do
more $fn | \
while read str; do
echo $str
var=$(echo $str | awk -F" " '{print $1,$2,$3,$4,$5}')
set -- $var
echo $1
echo $4
echo $5
done
done
It works, yeah~~