The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to extract duplicate rows bobbygsk Shell Programming and Scripting 5 11-20-2008 11:31 AM
How to delete particular rows from a file suresh3566 Shell Programming and Scripting 5 06-02-2008 06:07 AM
How to append a Value to all the rows in a file dsshishya Shell Programming and Scripting 2 03-20-2008 05:04 PM
Extract duplicate fields in rows anhtt Shell Programming and Scripting 6 12-02-2007 09:58 PM
alternate rows of a file dr46014 Shell Programming and Scripting 3 08-25-2007 07:16 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-22-2008
infyanurag infyanurag is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 65
duplicate rows in a file

hi all

can anyone please let me know if there is a way to find out duplicate rows in a file. i have a file that has hundreds of numbers(all in next row).
i want to find out the numbers that are repeted in the file.
eg.
123434
534
5575
4746767
347624
5575

i want 5575

please help
  #2 (permalink)  
Old 05-22-2008
penchal_boddu penchal_boddu is offline
Registered User
  
 

Join Date: Apr 2008
Location: Bangalore
Posts: 127
HI,

sort filename | uniq -c | awk ' $1 > 1 { print $2}'

Thanks
Penchal
  #3 (permalink)  
Old 05-22-2008
infyanurag infyanurag is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 65
Thumbs up

Quote:
Originally Posted by penchal_boddu View Post
HI,

sort filename | uniq -c | awk ' $1 > 1 { print $2}'

Thanks
Penchal
thanks

that worked

cheers
  #4 (permalink)  
Old 05-22-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,440
One solution using awk.

Code:
awk 'arr[$1]++' data.file

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:45 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0