shell linux unix xargs -i replace string

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















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 ?










share|improve this question



















  • 2





    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

    – steeldriver
    Mar 14 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.

    – Omar BISTAMI
    Mar 14 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)

    – steeldriver
    Mar 14 at 16:11

















0















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 ?










share|improve this question



















  • 2





    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

    – steeldriver
    Mar 14 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.

    – Omar BISTAMI
    Mar 14 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)

    – steeldriver
    Mar 14 at 16:11













0












0








0








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 ?










share|improve this question
















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 ?







linux shell-script shell xargs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 15 at 9:24







Omar BISTAMI

















asked Mar 14 at 11:32









Omar BISTAMIOmar BISTAMI

611110




611110







  • 2





    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

    – steeldriver
    Mar 14 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.

    – Omar BISTAMI
    Mar 14 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)

    – steeldriver
    Mar 14 at 16:11












  • 2





    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

    – steeldriver
    Mar 14 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.

    – Omar BISTAMI
    Mar 14 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)

    – steeldriver
    Mar 14 at 16:11







2




2





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

– steeldriver
Mar 14 at 13:39





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

– steeldriver
Mar 14 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.

– Omar BISTAMI
Mar 14 at 16:07






Yes, but the "xargs -ifil file fil" part, i do not understand this part.. for the rest i can get my head around it.

– Omar BISTAMI
Mar 14 at 16:07





1




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)

– steeldriver
Mar 14 at 16:11





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)

– steeldriver
Mar 14 at 16:11










1 Answer
1






active

oldest

votes


















2














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 barnqwertyn" | xargs -ixxx echo ":xxx:xxx:"
:foo bar:foo bar:
:qwerty:qwerty:





share|improve this answer























  • Thank you the example made it clear , i have also changed my title for search purpose.

    – Omar BISTAMI
    Mar 15 at 9:24











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f506261%2fshell-linux-unix-xargs-i-replace-string%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














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 barnqwertyn" | xargs -ixxx echo ":xxx:xxx:"
:foo bar:foo bar:
:qwerty:qwerty:





share|improve this answer























  • Thank you the example made it clear , i have also changed my title for search purpose.

    – Omar BISTAMI
    Mar 15 at 9:24















2














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 barnqwertyn" | xargs -ixxx echo ":xxx:xxx:"
:foo bar:foo bar:
:qwerty:qwerty:





share|improve this answer























  • Thank you the example made it clear , i have also changed my title for search purpose.

    – Omar BISTAMI
    Mar 15 at 9:24













2












2








2







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 barnqwertyn" | xargs -ixxx echo ":xxx:xxx:"
:foo bar:foo bar:
:qwerty:qwerty:





share|improve this answer













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 barnqwertyn" | xargs -ixxx echo ":xxx:xxx:"
:foo bar:foo bar:
:qwerty:qwerty:






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 14 at 18:43









ilkkachuilkkachu

63.4k10104181




63.4k10104181












  • Thank you the example made it clear , i have also changed my title for search purpose.

    – Omar BISTAMI
    Mar 15 at 9:24

















  • Thank you the example made it clear , i have also changed my title for search purpose.

    – Omar BISTAMI
    Mar 15 at 9:24
















Thank you the example made it clear , i have also changed my title for search purpose.

– Omar BISTAMI
Mar 15 at 9:24





Thank you the example made it clear , i have also changed my title for search purpose.

– Omar BISTAMI
Mar 15 at 9:24

















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f506261%2fshell-linux-unix-xargs-i-replace-string%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay