Slashdot Mirror


How To Adopt 10 'Good' Unix Habits

An anonymous reader writes to mention an article at the IBM site from earlier this week, which purports to offer good Unix 'habits' to learn. The ten simple suggestions may be common sense to the seasoned admin, but users with less experience may find some helpful hints here. From the article: "Quote variables with caution - Always be careful with shell expansion and variable names. It is generally a good idea to enclose variable calls in double quotation marks, unless you have a good reason not to. Similarly, if you are directly following a variable name with alphanumeric text, be sure also to enclose the variable name in square brackets ([]) to distinguish it from the surrounding text. Otherwise, the shell interprets the trailing text as part of your variable name -- and most likely returns a null value."

11 of 360 comments (clear)

  1. FP? by Shadow-isoHunt · · Score: 5, Funny

    export POST="first"

    --
    www.isoHunt.com
    1. Re:FP? by Anonymous Coward · · Score: 2, Funny

      Imbecile! POST wasn't defined yet! This won't work on /bin/sh, only with the proprietary bash shell.

  2. welll.. by macadamia_harold · · Score: 5, Funny

    An anonymous reader writes to mention an article at the IBM site from earlier this week, which purports to offer good Unix 'habits' to learn.

    I seriously doubt reading this article is going to get anyone to start showering on a regular basis.

    1. Re:welll.. by SharpFang · · Score: 5, Funny

      Ie there is NOTHING bad about piping cats

      PETA would disagree.

      --
      45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2
    2. Re:welll.. by jc42 · · Score: 3, Funny

      Ie there is NOTHING bad about piping cats

      PETA would disagree.


      Oh? Just imagine the cacophony of a bunch of cats playing bagpipes while "singing" along.

      --
      Those who do study history are doomed to stand helplessly by while everyone else repeats it.
    3. Re:welll.. by db32 · · Score: 2, Funny

      I frequently cat bleh | grep whatever just because it was the first way I learned and reflexively do it that way. grep whatever * actually tells me what file it found the match in, rather than just showing me the line. So while piping cats isn't inherently bad, there is frequently better ways to do it that also give more correct output, but it depends on what the desired output is. However "I grepped all the files for 'bleh'" sounds infinitely less disturbing than "I grepped what came out of the cat I piped"

      --
      The only change I can believe in is what I find in my couch cushions.
  3. Very helpful by EvanED · · Score: 5, Funny
    I really like this example:

    ~ $ time grep and tmp/a/longfile.txt | wc -l
    2811

    real 0m0.097s
    user 0m0.006s
    sys 0m0.032s
    ~ $ time grep -c and tmp/a/longfile.txt
    2811

    real 0m0.013s
    user 0m0.006s
    sys 0m0.005s


    I am so glad that he showed what a difference can make, because I was *really* getting annoyed at having to wait that extra .084 seconds.
    1. Re:Very helpful by trip11 · · Score: 3, Funny

      There is no such thing as .084 seconds. Surely you mean .084 hours.

  4. Re:Don't use shell by Bazman · · Score: 5, Funny

    If I've got a simple task to do (eg the text-file-of-URLS example) then I knock it up in shell script. By the time that simple task has feature-creeped up to more than 20 lines I start to wish I'd written it in Perl. So I rewrite. By the time that Perl script has crept up to more than 200 lines I start to wish it was written in Python. So I rewrite. By the time that Python script has crept up to 2000 lines I start to wish I'd farmed the job out to a team of programmers, and I give up caring what language its written in and make them do it as a web service. Then I write a small shell script to call their web service. When that shell script has feature-creeped up to more than 20 lines...

  5. Re:cat file | grep something by AndroidCat · · Score: 2, Funny

    Articles on terminating zombie children are always a treat too.

    --
    One line blog. I hear that they're called Twitters now.
  6. Re:Don't use shell by Fred_A · · Score: 2, Funny
    Um, whats wrong with

    wget -i filename
    It's not a shellscript, that's what wrong with it. Please pay attention next time.
    --

    May contain traces of nut.
    Made from the freshest electrons.