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
Crystal Crow 140 points

                                    # Basic syntax:
sort input_file | uniq -c 
# Sort the file first because uniq requires a sorted file to work

3.89 (9 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
bash count the number of non duplicate lines linux show only once duplicate lines find duplicate lines in file bash find duplicate lines in text file shell script bash print all duplicate lines bash check duplicate lines find duplicates in a file bash bash duplicate file n times print duplicated lines in column bashs count duplicate lines in file as 1 in unix count lines of file except duplicate lines linux count lines of file do not count duplicate lines linux check duplicate lines in unix file bash only keep duplicate lines bash repeat command n times bash find duplicate values in the file how to duplicate a line in bash find duplicate records shell script puty command check double email in file txt unix shell show duplicate lines find duplicate lines in text file linux command to check for double values cat duplicate lines how to find the duplicate lines in a file in unix using unique to find duplicates in a line terminal terminal identify duplicate strings uniq show duplicates print repeated lines with count command to check duplicate lines in unix linux command to check duplicate lines in unix bash find duplicate lines bash duplicate lines repeated values terminal grep bash search file for duplicate lines how to print only duplicate lines in unix bash count same lines in file bash check for duplicate lines bash find duplicate rows how to find repeting lines from bash find duplicate lines in file linux count duplicate lines in file linux bash show duplicate lines display only the lines that contain duplicates linux find repeting line in files ubuntu uqnie comand returns repeated values uniqe linux sorted repeared rows sort linux only duplicates find a line without duplicate linux bash count duplicate lines in a file bash only print duplicated lines
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source