Examples of using the uniq command

Examples of using the uniq command

To remove consecutive duplicate lines from a file:

   uniq acc_nos accounts

This removes all consecutive duplicate lines from the file acc_nos and places the output in the file accounts.


To list the consecutive duplicate lines and the number of times that each occurs:

   uniq -c tel_nos errors

This lists each of the consecutive duplicate lines in the file tel_nos and the number of times that each is repeated. The results are placed in the file errors.


[Home] [Search] [Index] This site maintained by unixhelp@math.rutgers.edu
This page was last updated on September 05, 2006 at 10:30 am and is maintained by webmaster@math.rutgers.edu.
For questions regarding courses and/or special permission, please contact mclausen@math.rutgers.edu.
For questions or comments about this site, please contact help@math.rutgers.edu.
© 2012 Rutgers, The State University of New Jersey. All rights reserved.