Eval & Xargs
eval
Give me another chance. Re-evaluate this line and execute it.
eval is incredibly useful if you have shell variables that include other shell variables, shell variables that include aliases, shell variables that include I/O redirectors, or all sorts of perversities. It's commonly used within shell scripts to "evaluate" commands that are built during execution.
xargs
http://www.unixreview.com/documents/s=8274/sam0306g/
Many UNIX professionals think the xargs command, construct and execute argument lists, is only useful for processing long lists of files generated by the find command.
The find-xargs command combination is a powerful tool.
Examining the "Too Many Arguments" Problem
eval
Give me another chance. Re-evaluate this line and execute it.
eval is incredibly useful if you have shell variables that include other shell variables, shell variables that include aliases, shell variables that include I/O redirectors, or all sorts of perversities. It's commonly used within shell scripts to "evaluate" commands that are built during execution.
xargs
http://www.unixreview.com/documents/s=8274/sam0306g/
Many UNIX professionals think the xargs command, construct and execute argument lists, is only useful for processing long lists of files generated by the find command.
The find-xargs command combination is a powerful tool.
Examining the "Too Many Arguments" Problem
pr -n 'find . -type f -mtime -1 -print'|lpr
find . -type f -mtime -1 -print|xargs pr -n |lp
find . -type f -name "*.txt" -print|xargs rm
find . -type f -name "*.txt" -exec rm {} \; -print
xargs One-Liners
find . -type f -name "*.txt" | xargs -i ksh -c "echo deleting {}; rm {}"
find . -type d -print|sed 's@^@/usr/project/@'|xargs mkdir -p
The following command creates in the usr/project directory, a copy of the current working directory structure.
in the usr/project directory, a copy of the current working directory structure:

0 Comments:
Post a Comment
<< Home