![]() |
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 |
| can anyone help with shell script command about searching word with grep command? | aintour | Shell Programming and Scripting | 2 | 10-14-2009 04:51 PM |
| Need to Write Shell Script based off of this shell command | Rally_Point | Shell Programming and Scripting | 3 | 06-10-2009 05:19 PM |
| Help with ssh command in shell script | vikash_k | Shell Programming and Scripting | 6 | 05-21-2009 11:20 AM |
| Sed command in shell script | Todd88 | Shell Programming and Scripting | 1 | 07-05-2008 01:15 PM |
| how to use cd command in shell script | LAKSHMI NARAYAN | Shell Programming and Scripting | 3 | 09-09-2007 06:04 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
shell script/sed command help
First off I have read the man pages for sed and am still having trouble working on a script to remove portions of a log:
My goal is to take a log file to be emailed, read the file and strip the portions away AFTER the line MIME-Version:1.0 and strip away until it to the line starting with Content-Type:application. (HOWEVER, i would like for the sed command to keep the boundry line written before the Content-Type:application line.) ex. removing everything bold and italicized. note this will be static so it wont always be the same information or linecount. Code:
MIME-Version: 1.0 --_002_67C1678059C61F408194E53907AFB5CC09FB7E8BE6ISEXMB01RPadr_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Here goes nothing. -----Original Message----- From: =20 Sent: Friday, November 13, 2009 2:42 PM To: Subject: send to myself This will be forwarded to mail2fax. --_002_67C1678059C61F408194E53907AFB5CC09FB7E8BE6ISEXMB01RPadr_ Content-Type: application/pdf; Any help would be appreciated. thank you. Last edited by radoulov; 1 Week Ago at 06:09 PM.. Reason: added code tags |
|
||||
|
Try this: -
Code:
nawk '
/MIME-Version: 1.0/{ print;s++ }
/Content-Type: application\/pdf/{
print l
print
s = 0
}
{ l = $0 }
(s){ next }
' infile
---------- Post updated at 10:21 PM ---------- Previous update was at 10:16 PM ---------- Or Code:
nawk '
/MIME-Version: 1.0/{ print;s++ }
/Content-Type: application\/pdf/{
print l
s = 0
}
{ l = $0 }
(s){ next }
{ print }
' infile
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|