using perl on the command line, like sed or awk

G

gorda

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
 
E

Eric J. Roode

(e-mail address removed) (gorda) wrote in
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'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top