![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | 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. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| split string using separetor | rinku | Shell Programming and Scripting | 10 | 06-16-2009 02:01 PM |
| Split a file with no pattern -- Split, Csplit, Awk | madhunk | UNIX for Dummies Questions & Answers | 10 | 12-17-2007 12:57 PM |
| KSH split string into variables | drd_2b | Shell Programming and Scripting | 5 | 04-23-2006 07:07 PM |
| split string help | senthilk615 | Shell Programming and Scripting | 4 | 03-27-2006 06:43 PM |
| split a string | gazingdown | Shell Programming and Scripting | 3 | 02-09-2006 05:34 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
To select all lines from beginning of the file up to but not including a specific line:
Code:
awk '{if (match($0,"string")) exit; print}' myfile
Code:
awk '{print; if (match($0,"string")) exit}' myfile
If you want to select groups of lines beginning with a line that contains "start" and through a line that contains "end": Code:
awk '/start/,/end/' myfile |
|
||||
|
That is a little different. There are different approaches. One way is to set a flag on that will then test true for remainder of file processing:
Code:
awk '/string/ {p=1}; p==1 {print}' myfile
Code:
awk '/string/ {p=1;next}; p==1 {print}' myfile
|
|
||||
|
Or, using the /from/,/to/ construct, you could use a to-string that you know would never be in the file, such as:
Code:
awk '/string/,/ue4R6TbWQ2Jk/' myfile |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|