The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
exclude a line big123456 Shell Programming and Scripting 3 04-24-2008 09:31 AM
deleting multiple records from a huge file at one time dsravan Shell Programming and Scripting 5 02-06-2008 08:17 AM
Count No of Records in File without counting Header and Trailer Records guiguy Shell Programming and Scripting 2 06-07-2007 09:15 AM
Exclude & Zip dreams5617 Shell Programming and Scripting 1 02-11-2007 05:01 PM
tar: how to exclude subdirectories? kymberm Filesystems, Disks and Memory 7 10-15-2002 12:53 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 04-28-2008
Registered User
 

Join Date: Feb 2007
Posts: 110
exclude multiple records

Hi
I need to exclude multiple records in file .Using grep -v ,can exclude that record
Ex: If want to exclude 0012777201,0012777202
use grep two times .Is there any command to achive this through single command ?( cann't use grep multiple times if need to exclude multiple records in husge file)

grep -v 0012777201 a.txt >a1.txt

grep -v 0012777202 a1.txt >a2.txt



a.txt
====
20080331|2505|0012777201|1|U|U|U|
20080331|2505|0012777202|1|U|U|U|
20080331|2505|0012777204|1|U|U|U|
20080331|2505|0012777205|1|U|U|U|
20080331|2505|0012777206|1|U|U|U|

Thanks,
MR
Reply With Quote
Forum Sponsor
  #2  
Old 04-29-2008
Registered User
 

Join Date: Oct 2007
Posts: 7
Hi,

You can overcome it by using doubt quotes, as follows.

grep -v "00127772*" a.txt >a1.txt


Thanks
Aketi
Reply With Quote
  #3  
Old 04-29-2008
SAV SAV is offline
Registered User
 

Join Date: Nov 2007
Location: Russia, Nizhniy Novgorod
Posts: 4
try egrep.
it can eat regular expressions
for your case:
egrep -v "001277720[12]" a.txt
or
egrep -v "00127772011|00127772012" a.txt
Reply With Quote
  #4  
Old 04-29-2008
Registered User
 

Join Date: Apr 2008
Posts: 2
Cut a string

Hi All,

i have a requirement to exclude .csv from a file
I used cut -d ".csv",but its not working.
Can you please help
Reply With Quote
  #5  
Old 04-29-2008
Registered User
 

Join Date: Feb 2007
Posts: 110
Hi

Its working,Thanks for your reply


Thanks
MR
Reply With Quote
  #6  
Old 04-29-2008
SAV SAV is offline
Registered User
 

Join Date: Nov 2007
Location: Russia, Nizhniy Novgorod
Posts: 4
but the most correct way is not using grep here. Because it potentially can match value from other fields.
Here is an awk solution:
awk '$3!=0012777201 && $3!=0012777202; BEGIN {FS="|"}' 1.txt
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
regex, regular expressions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:05 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0