|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to delete all lines before a specific word?
Let's say we have a file containing: Code:
alllllsadfsdasdf qwdDDDaassss ccxxcxc#2222 dssSSSSddDDDD D1Sqn2NYOHgTI Hello Alex ssS@3 Ok, and let's say we want to delete all words from D1Sqn2NYOHgTI and back, this means to delete the words (and the lines of them) : Code:
alllllsadfsdasdf qwdDDDaassss ccxxcxc#2222 dssSSSSddDDDD D1Sqn2NYOHgTI Can this be done? I need actually a command to delete the words before the D1Sqn2NYOHgTI (and itself), because I know the command which deletes empty lines... |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Code:
sed '1,/D1S/d' file or: Code:
awk 'f;/D1S/{f=1}' file |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
thx!!!
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| search a word and delete consecutive lines below it | vikas027 | Shell Programming and Scripting | 3 | 06-03-2009 02:02 AM |
| Delete specific lines from a file | itzz.me | Shell Programming and Scripting | 4 | 04-08-2009 04:12 PM |
| delete lines containing a specific word in afile | sireesha9 | Shell Programming and Scripting | 4 | 02-23-2009 05:07 AM |
| How to delete specific lines at the same time | zanetti321 | UNIX for Advanced & Expert Users | 1 | 03-24-2008 07:00 AM |
| Delete specific lines in a text file | dniz | Programming | 9 | 08-08-2005 08:30 AM |
|
|