Sometimes I code little scripts that do stuff, maybe i let them take arguments via the command line. Most of the calls end up being system calls, I use perl because .. Kinda feels right, checking the parameters passed in, etc etc.

I was considering that maybe I should look into just writing plain old bash for some of these.. So, how do we take parameters in bash.. aha.. simple enough, $1, $2, $3 are the positions of the arguments passed in broken up by spaces.

What if you want to use dash flag, like 'command -o val'

I thought.. this should be easy enough. And oh boy... Compared to perl's Getopt::Std.. . is bash getopts as much of an increible pain in the * as it looks like to be?? It's excruciating!

It seems that by comparison, bash is great if you know exactly what is going to happen, like, if you want to search your hard drive for empty directories and delete them- but if you want to do anything more intricate- you're looking for pain and anguish... My experience with bash is limited, so I may be having early rejection feelings.

Should one press on to experience it, getting more involved with bash then simple scripts?


In reply to bash vs perl by leocharre

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.