Forgot your password?
typodupeerror

Comment some UNIX habits (Score 1) 360

Clearly this post is too old for anyone to care about, so I'll do it just to mark the article.

While I agree with /. reader comments, I wanted to point out some other problems with the article:

  1. Avoid the use of || and && on the command line. They are squirrely between different systems, and as some other reader pointed out, you should just run a command and see what happens. You're not in a script. Also, I am afraid of A || B && C - what happens? A and C, B and C, or just A? Operator precedence matters.
  2. Be careful about tars. I spent 2 years managing open source, and found that while most authors correctly name a root of the extraction ./my-package-1.2.3, some just put all their files in the current directory. You need to "jail" your tars carefully.
  3. Why not do "grep 'Dec '" for that grep example, instead of invoking awk? Point is, look at your data, then decide the simplest way to handle it.
  4. Piping cats is a loopy comment. Nobody cares. Also, the wc -l saving 0.84 seconds is loopy, as well.
  5. If you find yourself using many backslashes to continue a line, then you should be writing a script. Actually, the best thing you can do is open a notepad-like editor and build your command line in that, then paste it to your shell window.

Now, for my tips:

  1. Never depend on a variable being set when doing a remove. That is, NEVER do "rm -rf $SOMEPATH/*" because if SOMEPATH is not set, guess what gets removed? Uh huh.
  2. Always back up your MBR before making serious changes to your filesystem. Do this using "dd if=/dev/hda of=mbr.bin bs=1 count=512" and ideally put it on a USB stick. It's free, takes little time, and you can always restore your MBR from a bootable Linux distro such as SysRescueCD (my fav) if you really hose things up.
  3. Quit using CSH, like some other poster said. Use bash. It's everywhere.
  4. Pipe error output into a file, not just stdout. Somecommand >output.txt 2>&1 will write everything including errors into output.txt. If you ignore the 2>&1 (which says, duplicate stdout and route stderr into it), you only get the normal output.

Hope this helps.

Slashdot Top Deals

Digital circuits are made from analog parts. -- Don Vonada

Working...