exclude multiple records


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users exclude multiple records
# 1  
Old 04-29-2008
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
# 2  
Old 04-29-2008
Hi,

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

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


Thanks
Aketi
# 3  
Old 04-29-2008
try egrep.
it can eat regular expressions
for your case:
egrep -v "001277720[12]" a.txt
or
egrep -v "00127772011|00127772012" a.txt
# 4  
Old 04-29-2008
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
# 5  
Old 04-29-2008
Hi

Its working,Thanks for your reply


Thanks
MR
# 6  
Old 04-29-2008
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Exclude multiple lines using grep

Hi, I'm working on a shell script that reports service status on a database server. There are some services that are in disabled status that the script should ignore and only check the services that are in Enabled status. I output the service configuration to a file and use that information to... (5 Replies)
Discussion started by: senthil3d
5 Replies

2. Shell Programming and Scripting

Exclude lines in a file with matches with multiple Strings using egrep

Hi I have a txt file and I would like to use egrep without using -v option to exclude the lines which matches with multiple Strings. Let's say I have some text in the txt file. The command should not fetch lines if they have strings something like CAT MAT DAT The command should fetch me... (4 Replies)
Discussion started by: Sathwik
4 Replies

3. Shell Programming and Scripting

Multiple Records from 1 Record

I need to make one record to multiple records based on occurence column in the record and change the date.For example below first record has 5 ,so need to create 5 records from one and change the date to 5 months.Occurence can be any number. I am unable to come with a script.Can some one help ... (5 Replies)
Discussion started by: traininfa
5 Replies

4. Shell Programming and Scripting

Match records from multiple files

Hi, I have 3 tab delimited text files which look like this. File1: PROTEINID DESCRIPTION PEPTIDES FRAMES GB://115298678 _gi_115298678_ref_NP_000055.2_ complement C3 precursor 45 55 GB://4502027 _gi_4502027_ref_NP_000468.1_ serum albumin preproprotein 34 73 Entrez://strain 11128 /... (3 Replies)
Discussion started by: Vavad
3 Replies

5. Shell Programming and Scripting

Split records into multiple records

Hi All, I am trying to split a record into multiple records based on a value. Input.txt "A",1,0,10 "B",2,0,10,15,20 "C",3,11,14,16,19,21,23 "D",1,0,5 My desired output is: "A",1,0,10 "B",2,0,10 "B",2,15,20 "C",3,11,14 "C",3,16,19 "C",3,21,23 (4 Replies)
Discussion started by: kmsekhar
4 Replies

6. Ubuntu

[Solved] Using Find with an exclude/exclude file

I am familiar with using tar and exclude/include files: tar zcf backup.dirs.tgz --files-from=include.mydirs --exclude-from=exclude.mydirs --no-recursion but was wondering if I could use find in the same way. I know that you can just specify the directories to exclude but my list is... (2 Replies)
Discussion started by: metallica1973
2 Replies

7. Shell Programming and Scripting

Multiple records based on :

Hi , I have the below source source data 1|2|3|:123:abc|4 1|2|a| | 5 1|2|3|4|:a:s:D.....:n|t Target data should be 1|2|3|:123:abc|4 1|2|3|:123:abc|4 1|2|a| | 5 1|2|3|4|:a:s:D.....:n|t 1|2|3|4|:a:s:D.....:n|t 1|2|3|4|:a:s:D.....:n|t 1|2|3|4|:a:s:D.....:n|t (3 Replies)
Discussion started by: mora
3 Replies

8. Shell Programming and Scripting

Multiple records based on ';' in the record

Hi All, I have a *.csv files in a die /pro/lif/dow, (pipe delimiter file), these files are having 8 columns and 6 column(CDR_LOGIC) records are populated as below, I need to incorporate the below logic in all the *.csv files. 11||:ColumnA||:ColumnB 123||:ColumnA IIF(:ColumnA = :ColumnC then... (6 Replies)
Discussion started by: shruthidwh
6 Replies

9. UNIX for Dummies Questions & Answers

How to Exclude multiple directories from find command?

Hi, Can some one help me how to exclude multiple directories using find command.. I have the directory structure below. /a/a1/b1 /a/c1/c2 /a/d1/d2/d3 I want to exlcude a1,c2and d3 from the above using find,can some one suggest pls.. thanks in advance... Use code tags... (1 Reply)
Discussion started by: jagadish_gaddam
1 Replies

10. Shell Programming and Scripting

exclude records with null fields

Hi, can I do something like this to add a condition of checking if the 4th field is number or space or blank also: awk -F, '$4 /^*||*/' MYFILE >> OTHERFILE I also want the other part i.e. I need to exclude all lines whose 4th field is space or blank or number: MYFILE a,b,c,d,e a,b,c,2,r... (2 Replies)
Discussion started by: praveenK_Dudala
2 Replies
Login or Register to Ask a Question