ctrl + r Starts a search through your history file.
Ask HN: Best Unix Tricks?
21–30 of 107 posts
Re: Ask HN: Best Unix Tricks?
#22http://www.commandlinefu.com
http://www.hiraeth.com/alan/tutorials/courses/Unix-Tools.pdf
and Powers / Peek' oreilly book "Unix Power tools" on google books
================================
IBM had a good series:
http://www.ibm.com/developerworks/linux/library/l-11sysadtip...
https://www.ibm.com/developerworks/linux/library/l-10sysadti...
http://www.linuxformat.co.uk/wiki/index.php/58_Cool_Hacks
http://www.ibm.com/developerworks/aix/library/au-productivit...
Re: Ask HN: Best Unix Tricks?
#23Re: Ask HN: Best Unix Tricks?
#24For example:
curl http://news.bbc.co.uk/ | pbcopy # copies a web-page to clipboard
Depending on what you are doing it can be very useful: pbpaste | sort | pbcopy # sort the contents of the clipboard.
Another useful feature of OS X is open, which uses the finder to open a file: open file.pdf
open music.mp3Re: Ask HN: Best Unix Tricks?
#25Re: Ask HN: Best Unix Tricks?
#26I love the '-exec' flag for find
Re: Ask HN: Best Unix Tricks?
#27The 4.4 BSD supplementary books (PSD, USD, SMM, etc.) are full of major documentation, with chapters on vi, awk, cc, yacc, gprof, etc. They're very old-school. (OpenBSD installs them with its default documentation, I think FreeBSD does as well.) Some parts will be obsolete, but the big ideas are the same. For example, it covers lex and yacc better in about ten pages each than the O'Reilly book could in twenty times that. Same with make, and several other major parts in the Unix toolchain.
For starters, learn to use: apropos, cron, the basics of sed and awk, the shebang, a real editor, screen or tmux, tar, gzip, and find. Read man pages, see where they lead you. Try to automate stuff, and go spelunking in the infrastructure for whatever Unix distro you use.
I also found that I learned a LOT by getting away from stuff that assumed Linux. Soooo much Linux newbie stuff is written by people who only know Linux (and may use GNOME for most things, really). You don't really learn Unix that way. Also, watch out for people who assume that bash is the standard shell. (A pet peeve of mine.)
Re: Ask HN: Best Unix Tricks?
#28 xargs -d '\n'
as in find * -type f | egrep -i '\.(gif|jpg|png)$' | xargs -d '\n' identify
I used to use find -print0 | xargs -0 but sometimes you want to insert filters in between or the file names aren't from find.Re: Ask HN: Best Unix Tricks?
#29Re: Ask HN: Best Unix Tricks?
#30For example:
ps -e | grep processname
will grab the pid of any process so that you can subsequently kill it.
sudo !! (run last command as sudo) is great too when you forget to type sudo on a regular basis like me.