Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > using perl on the command line, like sed or awk

Reply
Thread Tools

using perl on the command line, like sed or awk

 
 
gorda
Guest
Posts: n/a
 
      10-20-2003
Hello,

Using sed or awk, I can quickly parse and perform operations on the
command line itself as in:

cat file | sed 's/cat/dog'
cat file | awk ' /cat/ {print "found the cat"} '

How can i do something like the above in perl on the command line
without having to write a script in a seperate file?

Thanks
-s
 
Reply With Quote
 
 
 
 
Eric J. Roode
Guest
Posts: n/a
 
      10-20-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) (gorda) wrote in
news:(E-Mail Removed) m:

> Hello,
>
> Using sed or awk, I can quickly parse and perform operations on the
> command line itself as in:
>
> cat file | sed 's/cat/dog'
> cat file | awk ' /cat/ {print "found the cat"} '
>
> How can i do something like the above in perl on the command line
> without having to write a script in a seperate file?


perl -pe 's/cat/dog/' file

See 'perldoc perlrun'

--
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
 
Reply With Quote
 
 
 
 
Andrew Shitov
Guest
Posts: n/a
 
      10-21-2003
> How can i do something like the above in perl on the command line
> without having to write a script in a seperate file?



$ perl -e 'print 123;'

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sed/awk/perl: How to replace all spaces each with an underscore thatoccur before a specific string ? bolega Python 6 08-23-2009 12:45 AM
add blank lines after word MAC (sed/awk or perl??) NNTP Perl 2 04-07-2004 06:04 AM
regular expression for perl, tcl, sed, grep, awk Jay eL Perl Misc 2 12-09-2003 04:23 AM
using perl on the command line, like sed or awk gorda Perl Misc 3 10-21-2003 01:50 PM
sed awk or perl for this? NNTP Perl 13 09-30-2003 06:49 AM



Advertisments