Write a Shell Script To The lines Of A Given File Such That 1st line become last and last become 1st and so on
Shell Script To The lines Of A Given File Such That 1st line become last and last become 1st and so on Shell Script: clear l=`cat m.txt | wc -l` touch s1.txt touch a1.txt echo "Before reverse the file is:" cat m.txt echo "----------------------------------------" for((i=1;i<=$l;i++)) do cat m.txt | tail -n $i | head -n 1 > s1.txt cat s1.txt >> a1.txt done cat 0< a1.txt 1> m.txt echo "After reverse the file is" cat m.txt OUTPUT: [admin@localhost line wise file reverse]$ sh lrev.sh Before reverse the file is: i am xyz i read n vit computer science department i kk xyz is my name i am xyz xyz xyz xyz xyz xyz ---------------------------------------- After reverse the file is xyz xyz xyz xyz xyz i am xyz xyz is my name computer science department i kk i read n rkmrc i am vit
Tags:
Shell Script
0 comments