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: vp@example.com (Viktor Pavlenko)
- Date: 23 May 2001 18:54:49 +0900
- Content-Type: text/plain; charset="ISO-2022-JP"
- Reply-To: tlug@example.com
- Resent-From: tlug@example.com
- Resent-Message-ID: <1EIbLC.A.36.sj4C7@example.com>
- Resent-Sender: tlug-request@example.com
You can do it easy in perl too: perl -ne '/^Subject: Cron <.*?> (\S+)/ && print "$1\n"' < file Viktor >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>
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: Netiquette [was: REGEXP in perl questiion]
- Next by thread: Re: REGEXP in perl questiion
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links