[nycbug-talk] nifty(1)
Matthew Story
matt at tablethotels.com
Wed Dec 14 17:28:42 EST 2011
hoping to start a long-living thread filled with the community's (1)-fu, and discussion of the (1)-fu-ness. if this actually takes off, Henry <henry at tablethotels.com> has volunteered to compile this into a nifty port, filled only with nifty man pages full of fun hacks.
so what nifty shit do you do with "General Commands"? What are your favorite sh functions/patterns? How do you leverage the latent power of bc? When do you bust out awk? And what are the most useful sed, cut invocations you've found?
I'll kick it off with a sh/find/xargs pattern I'm quite fond of, which i call the `bax mv':
# move the contents of dir ($1) to target dir ($2)
bax_mv() {
find "$1" -depth 1 -maxdepth 1 -print0 |
xargs -0 sh -c '
target="$1"; shift
mv "$@" "$target"
' baxter_mv "$2"
}
# glob expansion is unreliable for scripting (too many args)
# and mv's interface is ill-suited to use with xargs ... enter bax_mv
baxter_mv dir1 dir2
who's up next?
More information about the talk
mailing list