The uniq
command in C Shell (csh) is used to filter out repeated lines in a sorted file. It reads the input and outputs only the unique lines, making it useful for data processing and analysis.
The basic syntax of the uniq
command is as follows:
uniq [options] [arguments]
-c
: Prefix each line with the number of occurrences.-d
: Only print duplicate lines.-u
: Only print unique lines (lines that are not repeated).-i
: Ignore case when comparing lines.Here are some practical examples of how to use the uniq
command:
uniq sorted_file.txt
uniq -c sorted_file.txt
uniq -d sorted_file.txt
uniq -u sorted_file.txt
uniq -i sorted_file.txt
uniq
, as it only removes adjacent duplicate lines.-c
option to quickly identify how many times each line appears, which can be helpful for data analysis.uniq
with other commands like sort
to enhance its functionality, for example:
sort unsorted_file.txt | uniq
uniq
processes input from standard input as well, so you can pipe data directly into it.