#! /bin/bash while read line do # set -- `echo $line` # echo $4 $1 >> /tmp/t$$ # Also awk can do it echo $line | awk '{print $4 " " $1}' >> /tmp/t$$ done sort /tmp/t$$ rm /tmp/t$$ # set -- If no arguments follow, then the positional parameters are unset. # Otherwise, the positional parameters are set to the arguments, # even if some of them begin with a ‘-’. # ref: https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html