Shell script reverse lines of a file
Q. How do I reverse lines of a file under Linux / UNIX bash shell?
A. You need to use the rev utility or command. It copies the specified files to the standard output, reversing the order of characters in every line. If no files are specified, the standard input is read.
Display one line
tail -1 /etc/passwd
Reverse one line
$ tail -1 /etc/passwd | rev
eslaf/nib/:csim/bil/rav/:,,,qsamsnd:43556:111:x:qsamsndShare this tutorial on:
Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter → Make a contribution via Paypal/Bitcoin →
Don't Miss Any Linux and Unix Tips Get nixCraft in your inbox. It's free: