LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-17-2008, 07:41 AM   #1
jyotijain21
LQ Newbie
 
Registered: Dec 2007
Posts: 3
Blog Entries: 1

Rep: Reputation: 0
How to find duplicate entries in shell


I want to find the duplicate entries in file in shell.
for example:
cat file.txt
23
45
45
1
23
24

thn the output gve me:

45
23

means entries which are duplicate
 
Old 03-17-2008, 08:19 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
looks a lot like homework, but check out the uniq and sort commands.
 
Old 03-17-2008, 09:07 AM   #3
jimbo1708
Member
 
Registered: Jan 2007
Location: Pennsylvania
Distribution: Ubuntu 8.10 Server/9.04 Desktop, openSUSE 11.1
Posts: 154

Rep: Reputation: 31
look at the documentation for sed...

- JB
 
Old 03-18-2008, 01:31 AM   #4
jyotijain21
LQ Newbie
 
Registered: Dec 2007
Posts: 3
Blog Entries: 1

Original Poster
Rep: Reputation: 0
cn smebody gve me exact solution... i tried with uniq and sort.. bt unable to do
 
Old 03-18-2008, 01:50 AM   #5
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,245
Blog Entries: 15

Rep: Reputation: 233Reputation: 233Reputation: 233
Code:
cat file.txt | sort | uniq -d
 
Old 06-23-2008, 01:17 AM   #6
jyotijain21
LQ Newbie
 
Registered: Dec 2007
Posts: 3
Blog Entries: 1

Original Poster
Rep: Reputation: 0
my file contains text like
user,friends,college

now i want delimiter after user
which will gve output like

friends,college
 
  


Reply

Tags
scripting, shell


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Duplicate daylight savings time entries ille.pugil42 Linux - Software 2 03-09-2007 01:17 PM
Duplicate entries in fstab jrdioko Linux - Software 3 08-14-2006 01:08 AM
duplicate entries in grub d_GeNeRiT Fedora 5 01-26-2006 07:22 AM
Duplicate Entries OpenSuSE 10.0 TMan459 Suse/Novell 3 10-19-2005 04:43 AM
need help booting the system - duplicate /etc/inittab entries? ksgill Linux - Newbie 1 05-10-2004 07:47 AM


All times are GMT -5. The time now is 02:34 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration