LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 02-14-2011, 11:30 AM   #1
jkeertir
Member
 
Registered: Mar 2008
Posts: 70

Rep: Reputation: 15
delete duplicate lines from a file which has one field different


Dear all,

I have a file as

|60|ED|IBM|1003|PID<C>|Short|Quote|BUY<|0|0.0000>|SELL<|500|164.6600>|0|2|
|60|ED|IBM|1028|PID<B>|Short|Quote|BUY<|300|164.4100>|SELL<|200|164.6500>|0|2|
|60|ED|IBM|1029|PID<B>|Short|Quote|BUY<|300|164.3100>|SELL<|300|164.6400>|0|2|
|60|ED|IBM|1030|PID<C>|Short|Quote|BUY<|0|0.0000>|SELL<|200|164.7300>|0|2|
|88|ED|IBM|1031|PID<N>|Short|Quote|BUY<|200|164.5100>|SELL<|100|164.5400>|6|2|BBO|BUY<|200|164.5100> |BBO|SELL<|100|164.5400>|

I want to delete
|60|ED|IBM|1030|PID<C>|Short|Quote|BUY<|0|0.0000>|SELL<|200|164.7300>|0|2|
as it is same with the first line with only 4 field different

Is there any way to do it using shell script.

With regards,
Keerti
 
Old 02-14-2011, 12:38 PM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 8,708

Rep: Reputation: 886Reputation: 886Reputation: 886Reputation: 886Reputation: 886Reputation: 886Reputation: 886
Read the man pages on files like head, tail, cut, and most of all sed
 
0 members found this post helpful.
Old 02-15-2011, 01:45 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,565

Rep: Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901
I second checking out sed. Here is a tutorial if you need more information.
 
  


Reply


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
Delete Duplicate Lines in a file, leaving only the unique lines left xmrkite Linux - Software 6 01-14-2010 07:18 PM
How to compare two lines and delete the duplicate line from a file? Shobhna Linux - Newbie 10 12-05-2008 02:08 PM
Finding duplicate lines in a file MikeyCarter Linux - Software 3 10-05-2008 06:28 PM
How to modify a field in few lines in a file and save the new file - in Perl rounak94 Programming 1 10-02-2008 08:43 PM
how do u delete duplicate lines bharatbsharma Programming 4 10-29-2007 07:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:23 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration