xargs. Can't tell you how many times I wrote quickie C programs and awk scripts to do what xargs does. http://sidvind.com/wiki/Xargs_by_example
And find, that's a nice alternative to xargs when your args are a huge set of files.
Unix Commands I Wish I’d Discovered Years Earlier
211–220 of 259 posts
Re: Unix Commands I Wish I’d Discovered Years Earlier
#212Command line globbing! For the uninitiated: Let's say my pwd is `/home/projects` and i want to edit `/home/projects/a_huge_sprawling_app/940j_394/lol/flight_controller.rb` `vim **/flight_controller.rb` opens our flight_controller.rb straight away. In terms of effort, this allows you to basically omit a `find -name` when you're in a rush to edit some damn file where the hell is it again damn we need to reevaluate this…
Thanks a lot for wising me up to the new hotness offered by bash 4+ (zsh is also pretty slow for me for some reason, even though people keep telling me to switch to that. Maybe I'm more impatient than most folks).
Re: Unix Commands I Wish I’d Discovered Years Earlier
#213`cd -` to go back to the previous directory. Saved me LOTS of time over the past few months.
Wow. Thanks for this. I always cursed myself for forgetting to pushd, and now it turns out I didn't need to!
Re: Unix Commands I Wish I’d Discovered Years Earlier
#214Never knew about the "cal" command. I especially like that you can quickly look up a previous or future month/year. >> cal 3 1973 quickly shows a calendar of March 1973
Right, you can use this to easily find the number of days in an arbitrary month in a script: % cal 2 1972 | tail +3 | wc -w 29
What am I doing wrong?
This worked like a charm though:
cal dec 2002 | tail -6 | wc -w
(since it always takes up 6 lines, even sep 1752)
Re: Unix Commands I Wish I’d Discovered Years Earlier
#215Earlier quoted context omitted.
Right, you can use this to easily find the number of days in an arbitrary month in a script: % cal 2 1972 | tail +3 | wc -w 29
tail: cannot open +3 for reading: No such file or directory What am I doing wrong? This worked like a charm though: cal dec 2002 | tail -6 | wc -w (since it always takes up 6 lines, even sep 1752)
Re: Unix Commands I Wish I’d Discovered Years Earlier
#216Re: Unix Commands I Wish I’d Discovered Years Earlier
#217If anyone is interested there were several great posts on Hacker News a while about about useful UNIX commands [1, 2, 3]. I have also created several screencasts about command commands like the following [4], and one about the Filesystem Hierarchy Standard [5]. ls man pwd cd top ps df du cp mv rm mkdir rmdir less cat vi [1] https://news.ycombinator.com/item?id=6046682 [2] https://news.ycombinator.com/item?id=5022457…
You should do a screencast of such infinitely useful classics as tac , tsort , and sl . (Actually, I have found use for those first two on occasion. ;)
Re: Unix Commands I Wish I’d Discovered Years Earlier
#218I believe xxd is actually part of vim and not a Unix command itself. It's used to support hex-editing binary files, but you can see why it's useful in other roles as well.
The origins of xxd seem to be a bit murky, as I've seen others say the same thing about xxd being available only if vim is installed, but I've never seen a Unix system that didn't have vi(m) included. $ man xxd | grep vi Use xxd as a filter within an editor such as vim(1) to hexdump a region Use xxd as a filter within an editor such as vim(1) to recover a binary Use xxd as a filter within an editor such as vim(1) to…
Re: Unix Commands I Wish I’d Discovered Years Earlier
#219I recently discovered whatis and I love it.
Yup, it's a great way to review a lot of commands without reading every man page. Want to find all the tools on your system that use the curses library (for user-friendly interfaces)? Try this: for i in `\ls /bin/* /sbin/* /usr/bin/* /usr/sbin/* | sort -u` ; do ldd $i 2>/dev/null | grep -q curses && whatis `basename $i` ; done | grep -v 'nothing appropriate' Don't know how your current path finds a program? Use which…
% type -a which
which is a shell builtin
which is /usr/bin/which
Convenient if you really want to know what you'll be calling.Re: Unix Commands I Wish I’d Discovered Years Earlier
#220My biggest improvement was about finding out about .inputrc and configuring the Bash to use VIM-keybindings which is pretty handy if you are used to the editor. Also the following mapping from ESC to pressing jf via imap jf was very nice as I find it much more ergonomic. And to use it in Bash I have set editing-mode vi set keymap vi $if mode=vi set keymap vi-insert "jf": vi-movement-mode $endif set show-all-if-ambigu…