ArticleDirectory
- Parameters
- Option
- Example
Show unique rows
Uniq [Options] [Input-File] [Output-File]
Uniq is used to display its input. Only one row is retained for consecutive duplicate rows. If the files are sorted, uniq ensures that the same two rows are not displayed.
Parameters
If noInput-File, ThenUniqThe data is read from the standard input. If noOutput-File, ThenUniqWrite to standard output
Option
-C: the number of times that the row appears in the input file at the beginning of the row.
-D: displays a copy of the duplicate row. No duplicate row is displayed.
-The first n columns are skipped during the f comparison.
-I: Ignore the case sensitivity when comparing rows.
-S n ignore the first n characters in each line
-U only displays rows that do not repeat
-W n does not compare the content after the nth character in each line
Example
Original file
$CatTest boy took bat homeboy took bat Homegirl took bat homedog brought hat home
Uniq
$UniqTestboy took bat Homegirl took bat homedog brought hat home
Show duplicate rows only once
Uniq-C
$Uniq-C Test2Boy took bat home1Girl took bat home3Dog brought hat home
Displays the number of consecutive occurrences of each row in a file.
Uniq-d
$Uniq-D testboy took bat homedog brought hat home
Show duplicate rows only
Uniq-u
$Uniq-U test girl took bat home
Only show rows that do not appear repeatedly
Uniq-F-S
$Uniq-F2-S2Test boy took bat home
Skips specified columns and characters for comparison.