Search This Blog

Shell script: loop through lines from file or command output

You can pipe command output to a while loop
echo /path/to/1.txt | while IFS=$'\t' read a b; do
   echo "${b}, ${a}"
done

Or loop through a text file:
while IFS=$'\t' read a b; do
   echo "${b}, ${a}"
done < /path/to/1.txt

No comments:

Post a Comment