[nycbug-talk] nifty(1)

Matthew Story matt at tablethotels.com
Wed Dec 14 17:35:20 EST 2011

... oh boy ... way for me to start things with a bug ... so like me, I always do something stupid like misplacing a decimal point ... fix inline.

On Dec 14, 2011, at 5:28 PM, Matthew Story wrote:

> 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"
    ' bax_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
bax_mv dir1 dir2
> who's up next?
> _______________________________________________
> talk mailing list
> talk at lists.nycbug.org
> http://lists.nycbug.org/mailman/listinfo/talk

More information about the talk mailing list