DISQUS

All about Linux: 10 Seconds Guide to Bash Shell Scripting

  • Paul Tarjan · 3 months ago
    Looks good.

    One small correction, it is ! (bang) not ! (ban). Bang is the loud sound of a gun. And sometimes #! is pronounced "shabang" : http://tldp.org/LDP/abs/html/sha-bang.html
  • alex · 3 months ago
    test $d -eq 25 ; echo $d
    test $s -lt 50; do_something

    should be

    test $d -eq 25 && echo $d
    test $s -lt 50 && do_something
  • Ravi · 2 months ago
    Thanks Alex. I wonder how I missed it. Corrected.
  • joe · 2 months ago
    I used to do bash scripting; now I just write in Ruby and pipe stuff back and forth to the command line when I want to run system commands. It might be a little more obfuscated, but damn is it easier, and my code ends up a lot cleaner than when I wrote in bash.
  • RealDeuce · 2 months ago
    Please for the love of POSIX, change the == string equality test to a single =. This works just as well and it is portable to other sh implementations (dash, sh, etc) as well as the test command /bin/test and /bin/[
  • Ravi · 2 months ago
    In my understanding, single = is used for assigning values to a variable. For comparing two variables, you use double == . I didn't know you could use one for the other. I will check it out.
  • Kegs · 1 month ago
    From a windows guy by trade but doing more and more on Mac and Solaris, thanks a bunch for this! Very quick and concise.
  • s0l1dsnak3123 · 1 month ago
    Very Concise! Thank you :)
  • NewLinuxUser · 2 weeks ago
    How do you find a file without giving it the path and then use the if/then/else statement? Ex: if [after searching for file it is found] then it's found, else it's not? Using if [ -e /home/$file ] doesn't cut it. What if I don't remember where I put the file? Can I somehow put the find command within the if statement?