Mailing List ArchiveSupport open source code!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: REGEXP in perl questiion
- To: tlug@example.com
- Subject: Re: REGEXP in perl questiion
- From: twistedhammer@example.com
- Date: Wed, 23 May 2001 01:42:10 -0800
- Content-transfer-encoding: 7BIT
- Content-type: text/plain; charset=US-ASCII
- In-reply-to: <F91J6pkNzPZrIkyPzGN0001064b@example.com>
- Priority: normal
- Reply-to: twiistedhammer@example.com
- Resent-From: tlug@example.com
- Resent-Message-ID: <7OnbwB.A.12.vV4C7@example.com>
- Resent-Sender: tlug-request@example.com
On 23 May 2001, at 8:44, Jean-Christian Imbeault wrote: > Ok, I admint it's lazy but could someone give me a regular expression > in Perl that would do the following? (I've tried for the last hour but > I'm not very good at regular expressions it seems). > > I have strings like the following: > > Subject: Cron <root@example.com> /root/AdminScripts/NSH.sh > Subject: Cron <root@example.com> /usr/bin/rsync -avzr --delete > /home/httpd/html/top40/* 10.0.1.53:/home/httpd/html/ > > I want to extract the name of the program that cron started, without > the switches if any. > Do you *need* to use perl? awk can handle this without the fuss.. 'BEGIN{ FS=" ";} { print "The program called by cron was ", $4; }' would print the 4th field which is what you are looking for plus the text. This assumes that the subject line is just the word 'Cron'. If you have a variable Subject: line this isn't going to work. YMMV. James Gibson twistedhammer@example.com
- Follow-Ups:
- Re: REGEXP in perl questiion
- From: Simon Cozens <simon@example.com>
- References:
- REGEXP in perl questiion
- From: "Jean-Christian Imbeault" <jean_christian@example.com>
Home | Main Index | Thread Index
- Prev by Date: Re: REGEXP in perl questiion
- Next by Date: Re: REGEXP in perl questiion
- Prev by thread: Re: REGEXP in perl questiion
- Next by thread: Re: REGEXP in perl questiion
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links