a simple hack related to xargs

$ls robinsons.iso
$ls | grep robinsons.iso | xargs rm
$ls robinsons.iso
ls: cannot access robinsons.iso: No such file or directory

xargs - build and execute command lines from standard input
This  manual  page  documents  the  GNU  version of xargs.  
xargs reads items from the standard input, delimited by blanks 
(which can be protected with double or single quotes or a backslash)
or newlines, and executes the command (default is /bin/echo) one or 
more times with any initial-arguments followed by items  read  
from  standard input.  Blank lines on the standard input are 
ignored. Because  Unix   filenames  can contain blanks and newlines,
this default behaviour is often  problematic; filenames containing 
blanks and/or newlines are incorrectly processed by xargs. In these
situations it is better to use the -0 option, which prevents such
problems. When using this option you will need to ensure that the 
program which produces the input for xargs also uses a null character
as a separator.  If that program is GNU find for example, the -print0
option does this for you.

Reference/Source :
Debian manual page for "xargs".

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s