cat $* | awk ' { lines[NR]=$0 }
END { for(i=NR;i>=0;i--)
{
ORS=" ";
split(lines[i],elements," ");
for(j=length(elements);j>=0;j--)
{
print elements[j];
}
ORS="\n";
print "";
}
}
'
OUTPUT:-
#!/bin/bash
#root@slack-linunx:~/scripts# cat > testFile
#ABCD EFGH
#IJKL MNOP
#root@slack-linunx:~/scripts# ./backwards.sh testFile
#MNOP IJKL
#EFGH ABCD
#root@slack-linunx:~/scripts#
END { for(i=NR;i>=0;i--)
{
ORS=" ";
split(lines[i],elements," ");
for(j=length(elements);j>=0;j--)
{
print elements[j];
}
ORS="\n";
print "";
}
}
'
OUTPUT:-
#!/bin/bash
#root@slack-linunx:~/scripts# cat > testFile
#ABCD EFGH
#IJKL MNOP
#root@slack-linunx:~/scripts# ./backwards.sh testFile
#MNOP IJKL
#EFGH ABCD
#root@slack-linunx:~/scripts#
0 comments:
Post a Comment