WAP to Reverse The Words In Given File Gain Infiniti

WAP to Reverse The Words In Given File


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#

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 

Design By Manish and Ranjan