Delete all rows that contain a specific string (text)


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Delete all rows that contain a specific string (text)
# 1  
Old 06-16-2011
Delete all rows that contain a specific string (text)

Hi,

I have a text file and I want to delete all rows that contain a particular string of characters. How do I go about doing that? Thanks!
# 2  
Old 06-16-2011
Try:
Code:
awk '!/your_string/' file

# 3  
Old 06-16-2011
Hi.

Perhaps with grep -v
# 4  
Old 06-16-2011
The awk code does not really work, because I want to delete the whole row that contains the specific string, not just that particular string and column.
# 5  
Old 06-16-2011
Did you try it? It should delete whole row...
# 6  
Old 06-16-2011
Quote:
Originally Posted by bartus11
Did you try it? It should delete whole row...
Yes, I did try. It only deleted the column that contains the string and not the first column.
# 7  
Old 06-16-2011
Maybe post your sample input and desired output.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete lines above and below specific line of text

I'm trying to remove a specific number of lines, above and below a specific line of text, highlighted in red: <STMTTRN> <TRNTYPE>CREDIT <DTPOSTED>20151205000001 <TRNAMT>10 <FITID>667800001 <CHECKNUM>667800001 <MEMO>BALANCE </STMTTRN> <STMTTRN> <TRNTYPE>DEBIT <DTPOSTED>20151207000001... (8 Replies)
Discussion started by: bomsom
8 Replies

2. Shell Programming and Scripting

How to delete lines starting with specific string?

Dear all, I would like to delete even lines starting with "N" together with their respective titles which are actually odd lines. Below is the example of input file. I would like to remove line 8 and 12 together with its title line, i.e., line 7 and 11, respectively.... (2 Replies)
Discussion started by: huiyee1
2 Replies

3. UNIX for Dummies Questions & Answers

Delete rows with unique value for specific column

Hi all I have a file which looks like this 1234|1|Jon|some text|some text 1234|2|Jon|some text|some text 3453|5|Jon|some text|some text 6533|2|Kate|some text|some text 4567|3|Chris|some text|some text 4567|4|Maggie|some text|some text 8764|6|Maggie|some text|some text My third column is my... (9 Replies)
Discussion started by: A-V
9 Replies

4. UNIX for Dummies Questions & Answers

Deleting specific rows from a text file

How do I go about deleting specific rows from a text file (given row number)? (5 Replies)
Discussion started by: evelibertine
5 Replies

5. UNIX for Dummies Questions & Answers

Help with deleting specific rows from a text file

I know this is a complicated question but I will try to illustrate it with some data. I have a data file that looks like the following: 1341 NA06985 0 0 2 46.6432798439 1341 NA06991 NA06993 NA06985 2 48.8478948517 1341 NA06993 0 0 1 45.8022601455 1340 NA06994 0 0 1 48.780669145 1340... (1 Reply)
Discussion started by: evelibertine
1 Replies

6. Shell Programming and Scripting

Delete rows in text file

Hi I do have a text file with 1000's of lines with 1 row and column with a specific pattern. 1102 1 1 1 1 1234 1 1 1 1 1009 1 1 1 1 1056 1 (3 Replies)
Discussion started by: Lucky Ali
3 Replies

7. Shell Programming and Scripting

How to delete rows by RowNumber from a Large text file

Friends, I have text file with 700,000 rows. Once I load this file to our database via our cutom process, it logs the row number for rejected rows. How do I delete rows from a Large text file based on the Row Number? Thanks, Prashant (8 Replies)
Discussion started by: ppat7046
8 Replies

8. Shell Programming and Scripting

delete strings till specific string

Hello i want to know a way so i can delete all the strings in file from the begning till a specific string (1 Reply)
Discussion started by: modcan
1 Replies

9. Shell Programming and Scripting

How do I delete all files that contain specific text?

Hi all, I want to remove the files from a folder whcih contain a specific text in it. eg: If i have the files like xxxx.NAME.adadd.ajfaj.kjfha agsg.NAME.dfshd.djsh.sdjhf asgd.NAME2.sdhj.djhf.sjdhf shdd.NAME2.dhse.tywe.eyio How to remove the files which contain the pattern "NAME"... (3 Replies)
Discussion started by: sparks
3 Replies

10. Programming

Delete specific lines in a text file

Hi, experts, I would like to create a function that can calculate the total number of lines in a saved text file and delete specific lines in that particular file (I only want the last few lines). Hav anybody have the experience and giv me a hand in this? (9 Replies)
Discussion started by: dniz
9 Replies
Login or Register to Ask a Question