Way to specify param for all commands executed
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I was wondering if there is a way to specify a mutual param for X amount of commands. E.g.
sudo cmd1 cmd2 cm3 --help
this obviously doesn't work, but I haven't seen anything in the manual. I'm assuming it can't be done, but didn't rule it out completely. If it doesn't exist, how can I go about making it?
shell command parameter
add a comment |Â
up vote
3
down vote
favorite
I was wondering if there is a way to specify a mutual param for X amount of commands. E.g.
sudo cmd1 cmd2 cm3 --help
this obviously doesn't work, but I haven't seen anything in the manual. I'm assuming it can't be done, but didn't rule it out completely. If it doesn't exist, how can I go about making it?
shell command parameter
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I was wondering if there is a way to specify a mutual param for X amount of commands. E.g.
sudo cmd1 cmd2 cm3 --help
this obviously doesn't work, but I haven't seen anything in the manual. I'm assuming it can't be done, but didn't rule it out completely. If it doesn't exist, how can I go about making it?
shell command parameter
I was wondering if there is a way to specify a mutual param for X amount of commands. E.g.
sudo cmd1 cmd2 cm3 --help
this obviously doesn't work, but I haven't seen anything in the manual. I'm assuming it can't be done, but didn't rule it out completely. If it doesn't exist, how can I go about making it?
shell command parameter
edited Nov 6 '17 at 14:18
terdonâ¦
123k28231403
123k28231403
asked Nov 6 '17 at 14:06
ThisGuyHasTwoThumbs
1979
1979
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
7
down vote
accepted
You'd have to use a loop:
for cmd in cmd1 cmd2 cmd3; do
"$cmd" --help
done
Or write a little function for it (add this to your shell's initialization file, ~/.bashrc
if using bash):
runWithParam()
param="$1"
shift
for cmd; do
"$cmd" "$param"
done
Then, run it with the parameter as the first parameter of the function:
runWithParam --help cmd1 cmd2 cmd3
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
7
down vote
accepted
You'd have to use a loop:
for cmd in cmd1 cmd2 cmd3; do
"$cmd" --help
done
Or write a little function for it (add this to your shell's initialization file, ~/.bashrc
if using bash):
runWithParam()
param="$1"
shift
for cmd; do
"$cmd" "$param"
done
Then, run it with the parameter as the first parameter of the function:
runWithParam --help cmd1 cmd2 cmd3
add a comment |Â
up vote
7
down vote
accepted
You'd have to use a loop:
for cmd in cmd1 cmd2 cmd3; do
"$cmd" --help
done
Or write a little function for it (add this to your shell's initialization file, ~/.bashrc
if using bash):
runWithParam()
param="$1"
shift
for cmd; do
"$cmd" "$param"
done
Then, run it with the parameter as the first parameter of the function:
runWithParam --help cmd1 cmd2 cmd3
add a comment |Â
up vote
7
down vote
accepted
up vote
7
down vote
accepted
You'd have to use a loop:
for cmd in cmd1 cmd2 cmd3; do
"$cmd" --help
done
Or write a little function for it (add this to your shell's initialization file, ~/.bashrc
if using bash):
runWithParam()
param="$1"
shift
for cmd; do
"$cmd" "$param"
done
Then, run it with the parameter as the first parameter of the function:
runWithParam --help cmd1 cmd2 cmd3
You'd have to use a loop:
for cmd in cmd1 cmd2 cmd3; do
"$cmd" --help
done
Or write a little function for it (add this to your shell's initialization file, ~/.bashrc
if using bash):
runWithParam()
param="$1"
shift
for cmd; do
"$cmd" "$param"
done
Then, run it with the parameter as the first parameter of the function:
runWithParam --help cmd1 cmd2 cmd3
edited Nov 6 '17 at 14:14
user4556274
4,97811123
4,97811123
answered Nov 6 '17 at 14:12
terdonâ¦
123k28231403
123k28231403
add a comment |Â
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f402835%2fway-to-specify-param-for-all-commands-executed%23new-answer', 'question_page');
);
Post as a guest
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
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
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