![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
![[community profile]](https://www.dreamwidth.org/img/silk/identity/community.png)
UNIX tips: Learn 10 good UNIX usage habits, as follows:
I learned a couple of things from this one!
- Make directory trees in a single swipe.
- Change the path; do not move the archive.
- Combine your commands with control operators.
- Quote variables with caution.
- Use escape sequences to manage long input.
- Group your commands together in a list.
- Use xargs outside of find .
- Know when grep should do the counting -- and when it should step aside.
- Match certain fields in output, not just lines.
- Stop piping cats.
I learned a couple of things from this one!
no subject
Date: 2011-11-24 06:50 am (UTC)no subject
Date: 2011-11-24 10:27 am (UTC)And ack is better than grep.
Get moreutils and pipetk.
Thank you for this! :-)
Date: 2011-11-25 07:19 pm (UTC)It's always good to pick tips and tricks, wherever they can be found.
The point with me is that I can always learn more to be a better UNIX user.
no subject
Date: 2011-11-26 04:16 am (UTC)no subject
Date: 2011-11-28 10:15 am (UTC)That said, while I'll always do "$cmd $file | ..." there is one thing to be said for the "cat $file | ..." style: when you're working on your super-huge command-line and you're still fine-tuning all the commands you're piping through, it's easier to leave the "cat $file" bit untouched, and then chop and change your filter commands ("Hmmm, maybe I want to swap the first grep and awk"), and tidy it up when you're done. If you're just testing how you're going to order your commands, then an extra fork/exec and pipe isn't going to kill you. :)
no subject
Date: 2012-02-09 11:28 pm (UTC)And nobody should pipe a cat. Cats are perfectly capable of getting into pipes themselves.
no subject
Date: 2012-02-09 11:30 pm (UTC)