I have hard time understanding the xargs part of this command :

find -type f | sed 's/ /\\ /g' | xargs -ifil file fil | \
   grep ELF | grep executable | cut -d: -f1 | xargs -ifil find fil -exec chmod 744 {} \;

What I have understood: looking for file not directory, then replacing " " by "\ ", then give the output to xargs that will pass it to the command file? why using the -i to replace? Then grep ELF and executable, take the first column by using : delimeter, do again an xargs with the same options to chmod 744 ?

  • 3
    IMHO it's such an ill-conceived command I'm not sure you will learn much from trying to pick it apart - it could be done better with a single find -exec and proper shell quoting Mar 14, 2019 at 13:39
  • Yes, but the "xargs -ifil file fil" part, i do not understand this part.. for the rest i can get my head around it. Mar 14, 2019 at 16:07
  • 1
    Well fil is just the author's choice for the replace-str - a more commonly used string is {} so for example you will often see xargs -I {} somecommand {} (the lower case i is also deprecated in favor of upper case I) Mar 14, 2019 at 16:11

1 Answer 1


Well, -istr is a (deprecated) alternative for -I str, and the GNU man page tells what -I does:

-I replace-str
      Replace  occurrences  of  replace-str  in the initial-arguments with 
      names read from standard input.  Also, unquoted blanks do not termi‐
      nate  input  items;  instead the separator is the newline character. 
      Implies -x and -L 1.

In other words, with -ixxx (or -Ixxx), xargs replaces the string xxx in the command given with the current item before running the command, and also makes xargs run the given command once for each input line, instead of the default where it stacks multiple items to a single command invocation, and considers whitespace-separated strings as distinct items.

E.g. here, the echo command runs twice, with xxx replaced by the contents of the two input lines as appropriate:

$ printf "foo bar\nqwerty\n" | xargs -ixxx echo ":xxx:xxx:"
:foo bar:foo bar:
  • Thank you the example made it clear , i have also changed my title for search purpose. Mar 15, 2019 at 9:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .