Live data from Hacker News

Ask HN: Best Unix Tricks?

news.ycombinator.com

21–30 of 107 posts

Re: Ask HN: Best Unix Tricks?

#22
post #3

http://www.commandlinefu.com

http://www.makeuseof.com/tag/4-websites-to-learn-cool-linux-...

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?

#24
On OS X pbcopy and pbpaste are useful for working with clipboard data. Copy data from a web-page or whatever, manipulate it on the command-line to get what you want. Putting reasonably large files in the clipboard can be useful too.

For 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.mp3

Re: Ask HN: Best Unix Tricks?

#27
Read man pages and "The Unix Programming Environment" by Kernighan and Pike. It's old, but conveys the design principles behind Unix, particularly how to write little tools that work well with all the others. "The Art of Unix Programming" is also good, despite Eric S. Raymond's getting on a soapbox all the time.

The 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?

#30
Pipes, grep and such come in handy in many applications.

For 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.

Post reply on HN