Tuesday, February 19, 2019

xargs command usage



Example on find all executables (ELF) and delete them in current directory:


find $PWD -type f | xargs file | grep "ELF.*executable" | awk -F: '{print $1}' | xargs  "rm"

Here, xargs is used which converts input into arguments to a command.

for example:

  • xargs file ->  file  <filename>
  • xargs rm ->  rm  <filename> 


--
find . -type f
- type f  ->  "find" only of file type.
--

No comments:

Post a Comment