Search and delete


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Search and delete
# 1  
Old 01-25-2010
Bug Search and delete

Gurus

I have a CSV containing 60K records.Each row has 8 columns.

On some rows ,for the 7th column ,i find word 'UnknownState(898914497)' repeated many times.

e.g

Code:
<N_HOST>   <tcp>     <*>      <*>       <*>       <*>       <CLOSINGIDLEUnknownState(425036765)UnknownState(425036795)UnknownState(425036835)UnknownState(425041673)UnknownState(878423377)UnknownState(878423382)UnknownState(878425279)......> <2010-01-20>

Query:

How can i open this file,search for string 'UnknownState' and delete it in such a way that the whole row gets deleted ?

Regards
Abhi
# 2  
Old 01-25-2010
Some possibilities:

Code:
grep -v 'UnknownState' file

or:
Code:
awk '!/UnknownState/' file

or:
Code:
sed '/UnknownState/d' file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Search and delete a row which is delimited by |^

I have a sample text file like this. CampaignId|^CampaignCd|^InsertionOrderCd|^OwningAdvertiserCd|^CampaignName 998201|^T15-06|^T15|^|^GTA 160x160 998277|^T15-07|^T15|^TEST|^GTA 160x160 998297|^T15-07|^T15|^TEST2|^GTA 160x160 I want to delete the line only when the 4th field is empty. ... (2 Replies)
Discussion started by: Tuxidow
2 Replies

2. UNIX for Beginners Questions & Answers

Search and Delete pattern with Control M

Hi I have data file like below: NET_SALES^M ^M---- new fields for -- ^M ,YABA_FLAG^M ,DOO_FLAG^M My requirement is to search for atleast 2 -- and remove all the words till first ^M is encountered. In above case, output should be like NET_SALES^M ^M ,YABA_FLAG^M ,DOO_FLAG^M TIA... (4 Replies)
Discussion started by: dashing201
4 Replies

3. Linux

How can I search and delete mail?

Hi, I'd like to delete emails on one of my Linux boxes using a criteria and I don't really know where to start. Any suggestions? The emails I'd like to delete have all the following sub-string: checkdefunct.sh.sh I have more than 187.000 emails and 90% of them I'd like to get rid of. ... (1 Reply)
Discussion started by: fabiogilr
1 Replies

4. Shell Programming and Scripting

all files-search and delete

I have n number of files like custpoten_123.txt custpoten_456.txt custpoten_789.txt custpoten_765.txt from above all files i want to serach for a particular number and it should delete the whole line.i have a code for search and delete. code is #!/usr/bin/sh... (6 Replies)
Discussion started by: katakamvivek
6 Replies

5. Shell Programming and Scripting

Search and delete

A file(example viv.txt) contains a n number of rows like 1,2,3,4,5,6,7,8 11,22,33,44,55,66,77,88 1,3,9,7,8,5,2,6,4 Requirement: If number "5" exist in the sixth position then it should delete the whole line.like this it should check for all rows in a file(viv.txt) . please help on this. (5 Replies)
Discussion started by: katakamvivek
5 Replies

6. Shell Programming and Scripting

search and delete the lines in a file

HI group members I am new in unix I want to search # symbol in a file. if found need to delete the entire row in the file. need to move the actual data(with out # symbol data) to another file. Thanks (2 Replies)
Discussion started by: pmreddy
2 Replies

7. UNIX for Dummies Questions & Answers

Linux novice - Search and delete

Hi unix masters, Im needing some guidance or a small code to enlight my problem. Problem Example: I have 3 different text ascii files. At each file, inside the text have repeater marks. --text 1 start-- 123 -> mark anytextanytext anythinganything 123 ->mark blahblah blah ...... (6 Replies)
Discussion started by: atnoz
6 Replies

8. Shell Programming and Scripting

search 2 lines and delete above line

Hi, I've been searching in this forum for the last 4 hours trying to do one thing: search 2 lines and delete the above line. So far I have not be able to find something similar in this forum, so I need help. This is what I'm trying to do. For example, I have a file called file1: file1 word1... (4 Replies)
Discussion started by: shamushamu
4 Replies

9. Shell Programming and Scripting

Search text and delete

After searching for a specified string, I would like to delete couple of rows from the file and continue searching. Basically, I would like to search through a text file that holds logs with date-time stamp in them and then clean up the file if the log entry is more than 2 days old. Example log... (0 Replies)
Discussion started by: new2shell
0 Replies

10. Shell Programming and Scripting

search and delete a line

Folks, I have a set of list that contains file names. I want to search through each of the list and delete any file that is found in the list. eg. LIST_A contains: aaa bbb ccc ddd eeee LIST_B contains: aab aac adb aed assuming I want to... (6 Replies)
Discussion started by: odogbolu98
6 Replies
Login or Register to Ask a Question