I think that knowing at least a little of some shell, sed and awk with perl reveals itself quite useful. You can do with perl everything you would do in the shell, I believe, but somethimes using the shell alone or coupling it with perl makes things simpler and/or faster. I'll try to show that with a few examples.

Whatching a log running, removing some unuseful lines and cleaning up others: here I prefer the shell, with tail and sed:

tail -f /logs/mail.log | sed -e '/last message repeated/d' -e 's/messa +ge forwarded from myhost: //i'

In a multiple-machine syslog, show only messages coming from a single host: awk can do the trick easily:

tail -f /logs/mail.log | awk '$4~/host/ { print }'

Read output from uptime and play a sound if load level in the last 5 seconds is lower than 0.4: here you can make the shell (bash) play with perl:

(while true ; do uptime ; sleep 3 ; done) | perl -ne '@load = /\d\.\d +\d/g ; print "\a" if $load[0] < .4 ; print "@load\n"'

but you could easily do the same using perl alone and backticks.

Summing up: you can make it knowing just perl, but knowing a good perl with a little of a shell and some basics of common unix tools can make your life easier.

My 2 cents (of Euro :-)
--bronto


In reply to Re: Perl vs. Shell Script by bronto
in thread Perl vs. Shell Script by ellem

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.