|
|||||||||
| Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here. |
unix and linux commands - unix shell scripting |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
sed delete lines containing text1 or text2
I'm trying to find all occurrences of lines with "sometext" or "someothertext" in them in a log file and remove them, then write the output to the same file, so far I have
sed '/sometext/d' logfile which gives me the lines I'm looking for, but how would I do: sed '/sometext/d' or '/someothertext/d' logfile > logfile what am I missing? |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
What you are doing should work fine. You just have to name the new file something else not the same file. Like: Code:
sed -e '/sometext/d' -e '/someothertext/d' logfile > logfilenew mv logfilenew logfile |
| Sponsored Links | ||
|
|
|
#3
|
||||
|
||||
|
THANKS!
I knew I was getting close, but you've definitely helped. |
| Sponsored Links | ||
|
|
![]() |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sed/awk to delete single lines that aren't touching other lines | slimjbe | Shell Programming and Scripting | 6 | 12-21-2011 01:37 PM |
| search and replace, when found, delete multiple lines, add new set of lines? | DeuceLee | Shell Programming and Scripting | 3 | 11-23-2011 04:39 PM |
| In a huge file, Delete duplicate lines leaving unique lines | krishnix | UNIX for Advanced & Expert Users | 16 | 08-04-2011 05:47 AM |
| How get only required lines & delete the rest of the lines in file | reva | UNIX for Dummies Questions & Answers | 7 | 06-01-2010 03:58 AM |
| How to delete lines in a file that have duplicates or derive the lines that aper once | necroman08 | Shell Programming and Scripting | 3 | 07-17-2009 06:07 AM |
|
|