![]() |
|
|
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 |
| deleting lines from multiple text files | vrms | Shell Programming and Scripting | 3 | 04-25-2008 12:01 PM |
| retrieved multiple lines on multiple places in a file | dala | Shell Programming and Scripting | 8 | 03-14-2008 03:28 PM |
| How to delete first 5 lines and last five lines in all text files | ragavendran31 | Shell Programming and Scripting | 10 | 02-21-2008 07:58 AM |
| Pulling data and following lines from file | MizzGail | Shell Programming and Scripting | 2 | 01-31-2006 03:13 PM |
| grep multiple text files in folder into 1 text file? | coppertone | UNIX for Dummies Questions & Answers | 7 | 08-23-2002 03:50 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Pulling multiple lines of text
Hello,
So, I'm not even sure if this will be possible for me to do (then again, that's why I'm asking for help )What I'm trying to do is pull multiple lines out of a very large text file, separating them into smaller files. Basically it's a text archive of a few hundred emails. What I have to work with is I do have a constant start line and end line. What I've been doing so far is to grep for the start of a message (grepping for '^From:' While this will pull the one line I am unsure as to how I can then get the next x number of lines to record into some sort of new text file and then stop at the known end line. (at the moment it's 30 '+' symbols...I don't know why, that's how it came) I'm thinking grep probably won't do all I want it to do. Should I be looking for something more along the lines of sed or awk? |
|
||||
|
Not sure how your file exactly looks like but the following awk command should be a good start. It searches for a pattern and prints the lines until a line begins with "++++": Code:
awk '
/^From:/{found=1}
found && $1 ~ /^++++/ {found=0}
found {print}' file
Regards |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|