Filter file according to pattern


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Filter file according to pattern
# 1  
Old 08-06-2010
Filter file according to pattern

Hello

I have an input file which is tab delimited.In my unix script I have search for a particular pattern.If it is NOT present then I have to write in an output file.
Eg.Input file is :
Code:
123  hello 7779 hi hkjh88 hahah
678  hello 90845 ti hkjsdfh 9324

And the search string is "123 hello hi".If all these are present in the particular line then the line should not be written to the output file.All other lines should be written.The output file will look like:
Code:
678  hello 90845 ti hkjsdfh 9324

The fields are present at fixed position of the tab-delimited line.In the above ex 1,2 and 4.
Plz help
Thanks
# 2  
Old 08-06-2010
Clear on the input and output . u said the files are pipe delimeited
Code:
123 | hello |7779 |hi |hkjh88 |hahah
678 | hello |90845| ti |hkjsdfh |9324

u need to search for the string
Code:
123 |hello| hi

whole string to match exactly or each field shouls me present or each field should me present at the correct position ? clear on that
# 3  
Old 08-06-2010
The file is a tab delimited not pipe delimeted.The fields will be present in the fixed positon.It will not be present anywhere else.So we can search the full line itself with the 3 patterns or the particular field also with the the corresponding search pattern.I guess the 1st option is much better.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Filter pattern in grep command

Hi, I am having a file like below hello how are you hello... (5 Replies)
Discussion started by: rohit_shinez
5 Replies

2. Shell Programming and Scripting

Shell script to filter records in a zip file that contains matching columns from another file

Not sure if this is the correct forum for this question. I have two files. file1.zip, file2 Input: file1.zip col1, col2 , col3 a , b , 0:0:0:0:0:c436:9346:d40b x, y, 0:0:0:0:0:880:39f9:c9a7 m, n , 0:0:0:0:0:80c7:9161:fe00 file2.txt col1 c4:36:93:46:d4:0b... (1 Reply)
Discussion started by: anil.v
1 Replies

3. Shell Programming and Scripting

Big pattern file matching within another pattern file in awk or shell

Hi I need to do a patten match between files . I am new to shell scripting and have come up with this so far. It take 50 seconds to process files of 2mb size . I need to tune this code as file size will be around 50mb and need to save time. Main issue is that I need to search the pattern from... (2 Replies)
Discussion started by: nitin_daharwal
2 Replies

4. Shell Programming and Scripting

sed - filter blocks between single delimiters matching a pattern

Hi! I have a file with the following format:CDR ... MSISDN=111 ... CDR ... MSISDN=xxx ... CDR ... MSISDN=xxx ... CDR ... MSISDN=111 (2 Replies)
Discussion started by: Flavius
2 Replies

5. UNIX for Dummies Questions & Answers

Filter records in a huge text file from a filter text file

Hi Folks, I have a text file with lots of rows with duplicates in the first column, i want to filter out records based on filter columns in a different filter text file. bash scripting is what i need. Data.txt Name OrderID Quantity Sam 123 300 Jay 342 498 Kev 78 2500 Sam 420 50 Vic 10... (3 Replies)
Discussion started by: tech_frk
3 Replies

6. Shell Programming and Scripting

Need help in a script to filter specific pattern

Hello , Below is the command srvctl config database -d cmdbut -s boms10.world Below is the output. Now in the command instead of cmdbut it will be a variable like $database which would be called in the script as below: srvctl config database -d $database -s $service Now,as shown in... (6 Replies)
Discussion started by: Vishal_dba
6 Replies

7. Shell Programming and Scripting

Search for a pattern in a String file and count the occurance of each pattern

I am trying to search a file for a patterns ERR- in a file and return a count for each of the error reported Input file is a free flowing file without any format example of output ERR-00001=5 .... ERR-01010=10 ..... ERR-99999=10 (4 Replies)
Discussion started by: swayam123
4 Replies

8. Shell Programming and Scripting

Filter a .kml file (xml) with data set from text file

I have a .kml file. So I want filter the .kml to get only the tags that have this numeric codes that they are in a text file 11951 11952 74014 11964 11965 11969 11970 11971 11972 60149 74018 74023 86378 11976 11980 11983 11984 11987 (5 Replies)
Discussion started by: pcoj33
5 Replies

9. Shell Programming and Scripting

To filter a certain pattern depending on neighbour

Hi, As I am new to filtering section of Unix I am facing a problem I have following lines in text file : Created RELEASE in dist/Apple_release_1_0_.zip Created RELEASE in dist/Banana_release_1_0_.zip Created RELEASE in dist/Mango_release_1_0_.zip Created RELEASE in... (2 Replies)
Discussion started by: bhaskar_m
2 Replies

10. Shell Programming and Scripting

Urgent! Sed/Awk Filter Find Pattern Delete Till End Of Line

Hi, I need help with using an awk or sed filter on the below line ALTER TABLE "ACCOUNT" ADD CONSTRAINT "ACCOUNT_PK" PRIMARY KEY ("ACCT_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "WMC_DATA" LOGGING ENABLE Look for... (2 Replies)
Discussion started by: rajan_san
2 Replies
Login or Register to Ask a Question