shell linux unix xargs -i replace string
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom: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 ?
linux shell-script shell xargs
add a comment |
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
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 singlefind -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
Wellfil
is just the author's choice for thereplace-str
- a more commonly used string isso for example you will often see
xargs -I somecommand
(the lower casei
is also deprecated in favor of upper caseI
)
– steeldriver
Mar 14 at 16:11
add a comment |
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
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
linux shell-script shell xargs
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 singlefind -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
Wellfil
is just the author's choice for thereplace-str
- a more commonly used string isso for example you will often see
xargs -I somecommand
(the lower casei
is also deprecated in favor of upper caseI
)
– steeldriver
Mar 14 at 16:11
add a comment |
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 singlefind -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
Wellfil
is just the author's choice for thereplace-str
- a more commonly used string isso for example you will often see
xargs -I somecommand
(the lower casei
is also deprecated in favor of upper caseI
)
– 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
add a comment |
1 Answer
1
active
oldest
votes
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:
Thank you the example made it clear , i have also changed my title for search purpose.
– Omar BISTAMI
Mar 15 at 9:24
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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:
Thank you the example made it clear , i have also changed my title for search purpose.
– Omar BISTAMI
Mar 15 at 9:24
add a comment |
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:
Thank you the example made it clear , i have also changed my title for search purpose.
– Omar BISTAMI
Mar 15 at 9:24
add a comment |
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:
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:
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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 thereplace-str
- a more commonly used string isso for example you will often see
xargs -I somecommand
(the lower casei
is also deprecated in favor of upper caseI
)– steeldriver
Mar 14 at 16:11