Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tlug: Re: bash ?



--------------------------------------------------------
tlug note from Jim Tittsler <jwt@example.com>
--------------------------------------------------------
Jim Schweizer <schweiz@example.com> writes:

I think you will find this is an 'ed' question, not a bash one.

> I'm trying to write a bash script that strips the header from
> mail files before I print them (XFMail won't do this and often
> the header is longer than the message) using ed. I must admit
> that the ed man page gave me a headache;-(
> 
> ed $1 << EOF
> 1,/^[]*$/d
      ^^ I don't think you can have an empty character set.
If you want to match any character, use a '.'.  However, what
I think you want is a blank line, which would be simply ^$
(i.e. the beginning of the line followed by the end of the line).
> w
> q
> EOF
> 
> When I try to use this ed counts the number of lines then exits
> with ?

Actually, it is probably printing the number of *characters* and
then complaining about the empty character set.  ed will show
the characters read and written if you give it valid commands
in your script.

BTW:  Instead of using 'ed', you might consider using the "stream"
version called 'sed'.  It is handy to stick in a pipe when you are
munging the data on the way somewhere else.  Perhaps you could 
create a shell script that looked like:

#!/bin/bash
sed -e "1,/^$/d" <$1 | lpr

which uses a command line script to delete the stuff up to and
including the first blank line on the way to lpring it.  Even
better if you can stick such a filter into your mailer's save
or print function.  (Or maybe even make a special printer
entry with such a default filter?)

-- 
Jim Tittsler, Tokyo  7j1ajh@example.com  http://shrine.cyber.ad.jp/~jwt/
-----------------------------------------------------------------
a word from the sponsor will appear below
-----------------------------------------------------------------
The TLUG mailing list is proudly sponsored by TWICS - Japan's First
Public-Access Internet System.  Now offering 20,000 yen/year flat
rate Internet access with no time charges.  Full line of corporate
Internet and intranet products are available.   info@example.com
Tel: 03-3351-5977   Fax: 03-3353-6096


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links