sh shell: how to use $1 inside quotes
Clash Royale CLAN TAG#URR8PPP
up vote
-1
down vote
favorite
I am using this code:
#!/bin/sh
if [ $# -lt 2 ]
then
echo "wrong syntax"
echo "ct_cmp.sh <label1> <label2> [<file_extension>]"
else
if [ $# -eq 2 ]
then
cleartool find . -version 'lbtype($1) && !lbtype($2)' -print
fi
fi
but get this result:
cleartool:
Error: Invalid query: "lbtype($1) && !lbtype($2)"
shell parameter
New contributor
add a comment |
up vote
-1
down vote
favorite
I am using this code:
#!/bin/sh
if [ $# -lt 2 ]
then
echo "wrong syntax"
echo "ct_cmp.sh <label1> <label2> [<file_extension>]"
else
if [ $# -eq 2 ]
then
cleartool find . -version 'lbtype($1) && !lbtype($2)' -print
fi
fi
but get this result:
cleartool:
Error: Invalid query: "lbtype($1) && !lbtype($2)"
shell parameter
New contributor
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I am using this code:
#!/bin/sh
if [ $# -lt 2 ]
then
echo "wrong syntax"
echo "ct_cmp.sh <label1> <label2> [<file_extension>]"
else
if [ $# -eq 2 ]
then
cleartool find . -version 'lbtype($1) && !lbtype($2)' -print
fi
fi
but get this result:
cleartool:
Error: Invalid query: "lbtype($1) && !lbtype($2)"
shell parameter
New contributor
I am using this code:
#!/bin/sh
if [ $# -lt 2 ]
then
echo "wrong syntax"
echo "ct_cmp.sh <label1> <label2> [<file_extension>]"
else
if [ $# -eq 2 ]
then
cleartool find . -version 'lbtype($1) && !lbtype($2)' -print
fi
fi
but get this result:
cleartool:
Error: Invalid query: "lbtype($1) && !lbtype($2)"
shell parameter
shell parameter
New contributor
New contributor
edited 2 days ago
Isaac
9,55411443
9,55411443
New contributor
asked 2 days ago
parafux
1
1
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
The single quote will prevent the expansion of the parameters in:
'lbtype($1) && !lbtype($2)'
It should work with "'lbtype($1) && !lbtype($2)'"
.
On a side note, one of my go-to tools when working on shell script is to validate them with shellcheck: https://www.shellcheck.net/ (also available in the standalone executable). Without surprise, it will tell you exactly the same thing about the simple quote.
apt-get install chellcheck
to install on debian and derivatives.
– ctrl-alt-delor
2 days ago
Do you still need the single quotes?
– ctrl-alt-delor
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
The single quote will prevent the expansion of the parameters in:
'lbtype($1) && !lbtype($2)'
It should work with "'lbtype($1) && !lbtype($2)'"
.
On a side note, one of my go-to tools when working on shell script is to validate them with shellcheck: https://www.shellcheck.net/ (also available in the standalone executable). Without surprise, it will tell you exactly the same thing about the simple quote.
apt-get install chellcheck
to install on debian and derivatives.
– ctrl-alt-delor
2 days ago
Do you still need the single quotes?
– ctrl-alt-delor
2 days ago
add a comment |
up vote
2
down vote
The single quote will prevent the expansion of the parameters in:
'lbtype($1) && !lbtype($2)'
It should work with "'lbtype($1) && !lbtype($2)'"
.
On a side note, one of my go-to tools when working on shell script is to validate them with shellcheck: https://www.shellcheck.net/ (also available in the standalone executable). Without surprise, it will tell you exactly the same thing about the simple quote.
apt-get install chellcheck
to install on debian and derivatives.
– ctrl-alt-delor
2 days ago
Do you still need the single quotes?
– ctrl-alt-delor
2 days ago
add a comment |
up vote
2
down vote
up vote
2
down vote
The single quote will prevent the expansion of the parameters in:
'lbtype($1) && !lbtype($2)'
It should work with "'lbtype($1) && !lbtype($2)'"
.
On a side note, one of my go-to tools when working on shell script is to validate them with shellcheck: https://www.shellcheck.net/ (also available in the standalone executable). Without surprise, it will tell you exactly the same thing about the simple quote.
The single quote will prevent the expansion of the parameters in:
'lbtype($1) && !lbtype($2)'
It should work with "'lbtype($1) && !lbtype($2)'"
.
On a side note, one of my go-to tools when working on shell script is to validate them with shellcheck: https://www.shellcheck.net/ (also available in the standalone executable). Without surprise, it will tell you exactly the same thing about the simple quote.
edited 2 days ago
Vlastimil
7,3371155131
7,3371155131
answered 2 days ago
Bear'sBeard
913
913
apt-get install chellcheck
to install on debian and derivatives.
– ctrl-alt-delor
2 days ago
Do you still need the single quotes?
– ctrl-alt-delor
2 days ago
add a comment |
apt-get install chellcheck
to install on debian and derivatives.
– ctrl-alt-delor
2 days ago
Do you still need the single quotes?
– ctrl-alt-delor
2 days ago
apt-get install chellcheck
to install on debian and derivatives.– ctrl-alt-delor
2 days ago
apt-get install chellcheck
to install on debian and derivatives.– ctrl-alt-delor
2 days ago
Do you still need the single quotes?
– ctrl-alt-delor
2 days ago
Do you still need the single quotes?
– ctrl-alt-delor
2 days ago
add a comment |
parafux is a new contributor. Be nice, and check out our Code of Conduct.
parafux is a new contributor. Be nice, and check out our Code of Conduct.
parafux is a new contributor. Be nice, and check out our Code of Conduct.
parafux is a new contributor. Be nice, and check out our Code of Conduct.
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%2f482138%2fsh-shell-how-to-use-1-inside-quotes%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