bash count duplicate lines in a file
# Basic syntax:
sort input_file | uniq -d
# Sort the file first because uniq requires a sorted file to work
# Note, uniq -d only prints one instance of lines that have duplicates
# Use, uniq -c to count the number of duplicates in the file
3.89
9
# Basic syntax:
sort input_file | uniq -c
# Sort the file first because uniq requires a sorted file to work
Thank you!
9
0
Are there any code examples left?
New code examples in category Shell/Bash