rev Command Examples in Linux

This tutorial explains Linux “rev” command, options and its usage with examples.

rev – reverse lines of a file

Description :

rev copies the specified files to the standard output and reverses the order of characters in every line.

If no files are specified, the standard input is read.

Usage :

advertisement
advertisement

rev [file]

Example :

Given a file abc.txt containing output of an ll command. Using rev utility, the reversed output is shown :

$ cat abc.txt
 
total 64
-rw-rw-r-- 1 abc abc 4096 Dec 20 06:23 abc
-rw-rw-r-- 1 abc abc    4 Dec 22 08:37 abv
drwxr-xr-x 2 abc abc 4096 Nov  8 05:32 Desktop
drwxr-xr-x 2 abc abc 4096 Nov  8 05:32 Documents
drwxr-xr-x 2 abc abc 4096 Dec 10 19:16 Downloads
-rw-r--r-- 1 abc abc 8942 Nov  8 05:24 examples.desktop
-rw-rw-r-- 1 abc abc   12 Dec 21 09:07 file1.txt
-rw-rw-r-- 1 abc abc   12 Dec 21 09:07 file2.txt
drwxr-xr-x 2 abc abc 4096 Nov  8 05:32 Music
drwxr-xr-x 2 abc abc 4096 Nov  8 05:32 Pictures
drwxr-xr-x 2 abc abc 4096 Nov  8 05:32 Public
drwxr-xr-x 2 abc abc 4096 Nov  8 05:32 Templates
drwxrwxr-x 2 abc abc 4096 Dec 24 10:51 Ubuntu One
drwxr-xr-x 2 abc abc 4096 Nov  8 05:32 Videos
 
$ rev abc.txt
 
46 latot
cba 32:60 02 ceD 6904 cba cba 1 --r-wr-wr-
vba 73:80 22 ceD 4    cba cba 1 --r-wr-wr-
potkseD 23:50 8  voN 6904 cba cba 2 x-rx-rxwrd
stnemucoD 23:50 8  voN 6904 cba cba 2 x-rx-rxwrd
sdaolnwoD 61:91 01 ceD 6904 cba cba 2 x-rx-rxwrd
potksed.selpmaxe 42:50 8  voN 2498 cba cba 1 --r--r-wr-
txt.1elif 70:90 12 ceD 21   cba cba 1 --r-wr-wr-
txt.2elif 70:90 12 ceD 21   cba cba 1 --r-wr-wr-
cisuM 23:50 8  voN 6904 cba cba 2 x-rx-rxwrd
serutciP 23:50 8  voN 6904 cba cba 2 x-rx-rxwrd
cilbuP 23:50 8  voN 6904 cba cba 2 x-rx-rxwrd
setalpmeT 23:50 8  voN 6904 cba cba 2 x-rx-rxwrd
enO utnubU 15:01 42 ceD 6904 cba cba 2 x-rxwrxwrd
soediV 23:50 8  voN 6904 cba cba 2 x-rx-rxwrd

Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.

If you wish to look at all Linux commands and their usage examples, go to Linux Commands Tutorial.

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.