Find a word and delete the line


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Find a word and delete the line
# 1  
Old 04-02-2008
Find a word and delete the line

Hi I have a text file like this name today.txt

the request has been accepted
the scan is successful at following time
there are no invalid packages
5169378 : map : Permission Denied
the request has been accepted

Now what i want do is

I want to search the today.txt file and

if i find "permission denied" then I have to delete the whole line.
so that the text looks like this,

the request has been accepted
the scan is successful at following time
there are no invalid packages
the request has been accepted


Any help is appreciated,

gns.
# 2  
Old 04-02-2008
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find word in a line and output in which line the word occurs / no. of times it occurred

I have a file: file.txt, which contains the following data in it. This is a file, my name is Karl, what is this process, karl is karl junior, file is a test file, file's name is file.txt My name is not Karl, my name is Karl Joey What is your name? Do you know your name and... (3 Replies)
Discussion started by: anuragpgtgerman
3 Replies

2. UNIX for Advanced & Expert Users

How to find a string in a line in UNIX file and delete that line and previous 3 lines ?

Hi , i have a file with data as below.This is same file. But actual file contains to many rows. i want to search for a string "Field 039 00" and delete that line and previous 3 lines in that file.. Can some body suggested me how can i do using either sed or awk command ? Field 004... (7 Replies)
Discussion started by: vadlamudy
7 Replies

3. UNIX for Dummies Questions & Answers

How to delete a particular word on particular line with sed?

I have a file from which I am trying to delete a particular word on a particular line. NEW NEW /v/engine NEW /ifs/list NEW /ifs/vdrome NEW I am trying to delete the first line only if it contains the word NEW. I am also trying to delete the last line only if it contains the word NEW. I... (11 Replies)
Discussion started by: newbie2010
11 Replies

4. UNIX for Dummies Questions & Answers

delete last word of each line a directory

I want to delete the last word of each line in all the files in one directory but dont know what I am doing wrong FILES="data/*" for X in $FILES do name=$(basename $X) sed s/'\w*$'// $X > no-last/${name} done Can you please help me :wall: (8 Replies)
Discussion started by: A-V
8 Replies

5. Shell Programming and Scripting

how to find third(nth) word in all line from a file

For example i'm having the below contents in a file: expr is great when you want to split a string into just two parts. The .* also makes expr good for skipping a variable number of words when you don't know how many words a string will have. But expr is lousy for getting, say, the fourth word... (2 Replies)
Discussion started by: bangarukannan
2 Replies

6. Shell Programming and Scripting

How to find frequent occurance of a word in a line?

File_source.DAT 1|abc|abc|abc|abc|abc 2|abc|abc|efg|efg|def 3|abc|bcd|cde|def|efg 4|abc|abc|abc|def|efg ========================= Please help me to solve this as below using UNIX. ========================= File_output.DAT "1"|"abc" - as... (3 Replies)
Discussion started by: scpyraj
3 Replies

7. Shell Programming and Scripting

Find specific line and delete line after.

I'm looking for a way to search a file, in this case init.rc for a specific match, service adbd /sbin/adbd, and delete the a specific line after it Original: # adbd is controlled by the persist.service.adb.enable system property service adbd /sbin/adbd disabled After deletion: #... (5 Replies)
Discussion started by: GabrialDestruir
5 Replies

8. Shell Programming and Scripting

SED to delete last word on line...what's wrong?

I have a line that gets pulled from a database that has a variable number of fields, fields can also be of a variable size. Each field has a variable number of spaces between them so there is no 'defined' delimiter. The LastData block is always a single word. What I want to do is delete the... (2 Replies)
Discussion started by: Bashingaway
2 Replies

9. Shell Programming and Scripting

delete line containin specified word

write a shell script that deletes all lines containing a specified word in one or more files supplied as arguments to it.help is appreciated .thank you. (2 Replies)
Discussion started by: shawz
2 Replies

10. UNIX for Advanced & Expert Users

Delete a word and complete line

Hi Canone please provide me solution how can achieve the result below: File1.txt $ sweet appleŁ1 scotish green $ This is a test1 $ sweet mangoŁ2 asia yellow $ This is a test 2 $ sweet apple red (there is no pound symbol here) germany green (1 Reply)
Discussion started by: Aejaz
1 Replies
Login or Register to Ask a Question