News for hackers. Stuff that matters.
Re:Ask HN: Best Command-Line Applications? by znpy on Monday November 19, 2018 @07:12AM (#18485832)
I am getting fonder and fonder of xargs. It basically reads some input and appends it to a pre-supplied string. Then executes the newly created string as a command.

Trivial example:

    ls -1 | xargs -L1 echo processing 

I am finding it quite useful to load and delete a bunch of netapp volume snapshots in a single line:

    ssh netappuser@netapphost volume snapshot show $volname | awk '/selector_pattern/{print $1}' | xargs -L1 ssh netappuser@netapphost volume snapshot delete $volname
Re:Ask HN: Best Command-Line Applications? by aptmiguk on Monday November 19, 2018 @07:18AM (#18485868)
With xargs (and find), I wish I would've found this sooner:

find test -print0 | xargs -0 file

"This allows file names that contain newlines or other types of white space to be correctly interpreted by programs that process the find output. This option corresponds to the -0 option of xargs."

Re:Ask HN: Best Command-Line Applications? by tyingq on Monday November 19, 2018 @08:33AM (#18486260)
Perl also supports -0 and is handy for some use cases because it won't spawn a process per line like xargs.

  # remove files without spawning lots of rm processes
  find . -name "*.xyz" -print0 -type f| perl -0 -ne 'chomp;print "$_\n";unlink;'