How to pass argument to subshell
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Is it possible to pass DBNAME argument to subshell without manually writing it?
mysqldump -u USERNAME -p DBNAME > "$(date +"%Y-%m-%d_%H-%M-%S")_DBNAME.sql"
bash shell command-line command
add a comment |Â
up vote
0
down vote
favorite
Is it possible to pass DBNAME argument to subshell without manually writing it?
mysqldump -u USERNAME -p DBNAME > "$(date +"%Y-%m-%d_%H-%M-%S")_DBNAME.sql"
bash shell command-line command
Similar (no dupe): unix.stackexchange.com/questions/436784/â¦
â Kusalananda
Apr 10 at 17:03
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Is it possible to pass DBNAME argument to subshell without manually writing it?
mysqldump -u USERNAME -p DBNAME > "$(date +"%Y-%m-%d_%H-%M-%S")_DBNAME.sql"
bash shell command-line command
Is it possible to pass DBNAME argument to subshell without manually writing it?
mysqldump -u USERNAME -p DBNAME > "$(date +"%Y-%m-%d_%H-%M-%S")_DBNAME.sql"
bash shell command-line command
asked Apr 10 at 15:15
J. Doe
11
11
Similar (no dupe): unix.stackexchange.com/questions/436784/â¦
â Kusalananda
Apr 10 at 17:03
add a comment |Â
Similar (no dupe): unix.stackexchange.com/questions/436784/â¦
â Kusalananda
Apr 10 at 17:03
Similar (no dupe): unix.stackexchange.com/questions/436784/â¦
â Kusalananda
Apr 10 at 17:03
Similar (no dupe): unix.stackexchange.com/questions/436784/â¦
â Kusalananda
Apr 10 at 17:03
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
There is no sub-shell here, but a command substitution (the $(...)
). If DBNAME
is a variable, you can use
DBNAME=mydatabase
mysqldump -u USERNAME -p "$DBNAME" > "$(date +"%F_%H-%M-%S")_$DBNAME.sql"
or even
DBNAME=mydatabase
mysqldump -u USERNAME -p "$DBNAME" >"$(date +"%F_%H-%M-%S_$DBNAME.sql")"
or
DBNAME=mydatabase
outfilename=$(date +"%F_%H-%M-%S_$DBNAME.sql")
mysqldump -u USERNAME -p "$DBNAME" >"$outfilename"
or variations thereof.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
There is no sub-shell here, but a command substitution (the $(...)
). If DBNAME
is a variable, you can use
DBNAME=mydatabase
mysqldump -u USERNAME -p "$DBNAME" > "$(date +"%F_%H-%M-%S")_$DBNAME.sql"
or even
DBNAME=mydatabase
mysqldump -u USERNAME -p "$DBNAME" >"$(date +"%F_%H-%M-%S_$DBNAME.sql")"
or
DBNAME=mydatabase
outfilename=$(date +"%F_%H-%M-%S_$DBNAME.sql")
mysqldump -u USERNAME -p "$DBNAME" >"$outfilename"
or variations thereof.
add a comment |Â
up vote
1
down vote
There is no sub-shell here, but a command substitution (the $(...)
). If DBNAME
is a variable, you can use
DBNAME=mydatabase
mysqldump -u USERNAME -p "$DBNAME" > "$(date +"%F_%H-%M-%S")_$DBNAME.sql"
or even
DBNAME=mydatabase
mysqldump -u USERNAME -p "$DBNAME" >"$(date +"%F_%H-%M-%S_$DBNAME.sql")"
or
DBNAME=mydatabase
outfilename=$(date +"%F_%H-%M-%S_$DBNAME.sql")
mysqldump -u USERNAME -p "$DBNAME" >"$outfilename"
or variations thereof.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
There is no sub-shell here, but a command substitution (the $(...)
). If DBNAME
is a variable, you can use
DBNAME=mydatabase
mysqldump -u USERNAME -p "$DBNAME" > "$(date +"%F_%H-%M-%S")_$DBNAME.sql"
or even
DBNAME=mydatabase
mysqldump -u USERNAME -p "$DBNAME" >"$(date +"%F_%H-%M-%S_$DBNAME.sql")"
or
DBNAME=mydatabase
outfilename=$(date +"%F_%H-%M-%S_$DBNAME.sql")
mysqldump -u USERNAME -p "$DBNAME" >"$outfilename"
or variations thereof.
There is no sub-shell here, but a command substitution (the $(...)
). If DBNAME
is a variable, you can use
DBNAME=mydatabase
mysqldump -u USERNAME -p "$DBNAME" > "$(date +"%F_%H-%M-%S")_$DBNAME.sql"
or even
DBNAME=mydatabase
mysqldump -u USERNAME -p "$DBNAME" >"$(date +"%F_%H-%M-%S_$DBNAME.sql")"
or
DBNAME=mydatabase
outfilename=$(date +"%F_%H-%M-%S_$DBNAME.sql")
mysqldump -u USERNAME -p "$DBNAME" >"$outfilename"
or variations thereof.
edited Apr 10 at 15:37
answered Apr 10 at 15:19
Kusalananda
102k13200317
102k13200317
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%2f436800%2fhow-to-pass-argument-to-subshell%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
Similar (no dupe): unix.stackexchange.com/questions/436784/â¦
â Kusalananda
Apr 10 at 17:03