Skip to content

Mad Command Line Skillz

I’ve been working with shell scripts recently. The *NIX command line has some really powerful tools, but I’m afraid to say I’m starting to feel pretty comfortable in my Java IDE land, or in Python land, hell even in Ruby land. And going back to shell scripting has not been fun for me.

A few tips:

  1. Use the debugger. Add -x to the shebang line and get this:
    #!/bin/sh -x
  2. Send output to a file:
    ls -l > ls-l.txt use this all the time so you don’t have to cut and paste from the terminal.
  3. Send stderr to a file too Why stop with stdout?
    grep da * 2> grep-errors.txt
  4. Merge them Go crazy, why have two files when you can just have one?
    grep da * 1>&2
  5. Go both ways, no, I’m not promoting both sides of the fence, but
    grep * 2>&1
  6. Run in Stealth Mode Don’t try this at home.
    rm -f $(find / -name core) &> /dev/output.txt
  7. [Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*