我需要反转包含以下内容的文本文件的字段:
Computer science is fun
I also enjoy math
But I don't like science
我需要awk
输出:
line 1: Computer science is fun
line 1 reversed: fun is science Computer
line 2: I also enjoy math
line 2 reversed: math enjoy also I
....... 等等。这就是我现在所拥有的:
BEGIN {print "start"}
{
for(i=NF; i>=1; i--)
{
printf "line %d: %s\n", NR , $0;
printf "line %d: reversed: %s", NR, $i;
}
}