what does it mean shell read command line arguments $1,,
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
In the Shell script code, the command line arguments assigned to variable like below. what does it mean comma(,) in the statement. What will be the difference when comma is added twice while reading the command line arguments in Bash script.
#!/bin/bash
var1=$1,,
var2=$2,,
./script.sh value1 value2
bash variable-substitution parameter
add a comment |Â
up vote
0
down vote
favorite
In the Shell script code, the command line arguments assigned to variable like below. what does it mean comma(,) in the statement. What will be the difference when comma is added twice while reading the command line arguments in Bash script.
#!/bin/bash
var1=$1,,
var2=$2,,
./script.sh value1 value2
bash variable-substitution parameter
1
Are you sure it's not./script "$var1" "$var2"
instead?
â Stéphane Chazelas
Oct 9 '17 at 13:05
@StéphaneChazelas - Its not "$var1" "$var2". Inside the script, while assigning the value there is double comma.
â arunp
Oct 10 '17 at 7:32
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
In the Shell script code, the command line arguments assigned to variable like below. what does it mean comma(,) in the statement. What will be the difference when comma is added twice while reading the command line arguments in Bash script.
#!/bin/bash
var1=$1,,
var2=$2,,
./script.sh value1 value2
bash variable-substitution parameter
In the Shell script code, the command line arguments assigned to variable like below. what does it mean comma(,) in the statement. What will be the difference when comma is added twice while reading the command line arguments in Bash script.
#!/bin/bash
var1=$1,,
var2=$2,,
./script.sh value1 value2
bash variable-substitution parameter
bash variable-substitution parameter
edited Oct 9 '17 at 12:32
asked Oct 9 '17 at 12:29
arunp
235
235
1
Are you sure it's not./script "$var1" "$var2"
instead?
â Stéphane Chazelas
Oct 9 '17 at 13:05
@StéphaneChazelas - Its not "$var1" "$var2". Inside the script, while assigning the value there is double comma.
â arunp
Oct 10 '17 at 7:32
add a comment |Â
1
Are you sure it's not./script "$var1" "$var2"
instead?
â Stéphane Chazelas
Oct 9 '17 at 13:05
@StéphaneChazelas - Its not "$var1" "$var2". Inside the script, while assigning the value there is double comma.
â arunp
Oct 10 '17 at 7:32
1
1
Are you sure it's not
./script "$var1" "$var2"
instead?â Stéphane Chazelas
Oct 9 '17 at 13:05
Are you sure it's not
./script "$var1" "$var2"
instead?â Stéphane Chazelas
Oct 9 '17 at 13:05
@StéphaneChazelas - Its not "$var1" "$var2". Inside the script, while assigning the value there is double comma.
â arunp
Oct 10 '17 at 7:32
@StéphaneChazelas - Its not "$var1" "$var2". Inside the script, while assigning the value there is double comma.
â arunp
Oct 10 '17 at 7:32
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
4
down vote
It's a parameter expansion called Case modification (see man bash
).
$var1
will contain the first argument with all characters converted to lowercase. Single ,
would only change the first character of the parameter.
You can specify a pattern for each character after the comma(s), e.g. the following will only lowercase vowels:
x=$(echo A..Z)
echo $x,,[AEIOU]
Output:
a B C D e F G H i J K L M N o P Q R S T u V W X Y Z
Symmetrically, you can use ^
to convert to upper case.
Nice to know these features. Maybe, only bash man pages provides lot of advanced stuff.
â arunp
Oct 9 '17 at 12:46
add a comment |Â
up vote
2
down vote
man bash | grep -B1 -A10 ,,
$parameter,pattern
$parameter,,pattern
Case modification. This expansion modifies the case of alphaâÂÂ
betic characters in parameter. The pattern is expanded to proâÂÂ
duce a pattern just as in pathname expansion. Each character in
the expanded value of parameter is tested against pattern, and,
if it matches the pattern, its case is converted. The pattern
should not attempt to match more than one character. The ^
operator converts lowercase letters matching pattern to upperâÂÂ
case; the , operator converts matching uppercase letters to lowâÂÂ
ercase. The ^^ and ,, expansions convert each matched character
in the expanded value; the ^ and , expansions match and convert
only the first character in the expanded value. If pattern is
omitted, it is treated like a ?, which matches every character.
If parameter is @ or *, the case modification operation is
applied to each positional parameter in turn, and the expansion
is the resultant list. If parameter is an array variable subâÂÂ
scripted with @ or *, the case modification operation is applied
to each member of the array in turn, and the expansion is the
resultant list.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
It's a parameter expansion called Case modification (see man bash
).
$var1
will contain the first argument with all characters converted to lowercase. Single ,
would only change the first character of the parameter.
You can specify a pattern for each character after the comma(s), e.g. the following will only lowercase vowels:
x=$(echo A..Z)
echo $x,,[AEIOU]
Output:
a B C D e F G H i J K L M N o P Q R S T u V W X Y Z
Symmetrically, you can use ^
to convert to upper case.
Nice to know these features. Maybe, only bash man pages provides lot of advanced stuff.
â arunp
Oct 9 '17 at 12:46
add a comment |Â
up vote
4
down vote
It's a parameter expansion called Case modification (see man bash
).
$var1
will contain the first argument with all characters converted to lowercase. Single ,
would only change the first character of the parameter.
You can specify a pattern for each character after the comma(s), e.g. the following will only lowercase vowels:
x=$(echo A..Z)
echo $x,,[AEIOU]
Output:
a B C D e F G H i J K L M N o P Q R S T u V W X Y Z
Symmetrically, you can use ^
to convert to upper case.
Nice to know these features. Maybe, only bash man pages provides lot of advanced stuff.
â arunp
Oct 9 '17 at 12:46
add a comment |Â
up vote
4
down vote
up vote
4
down vote
It's a parameter expansion called Case modification (see man bash
).
$var1
will contain the first argument with all characters converted to lowercase. Single ,
would only change the first character of the parameter.
You can specify a pattern for each character after the comma(s), e.g. the following will only lowercase vowels:
x=$(echo A..Z)
echo $x,,[AEIOU]
Output:
a B C D e F G H i J K L M N o P Q R S T u V W X Y Z
Symmetrically, you can use ^
to convert to upper case.
It's a parameter expansion called Case modification (see man bash
).
$var1
will contain the first argument with all characters converted to lowercase. Single ,
would only change the first character of the parameter.
You can specify a pattern for each character after the comma(s), e.g. the following will only lowercase vowels:
x=$(echo A..Z)
echo $x,,[AEIOU]
Output:
a B C D e F G H i J K L M N o P Q R S T u V W X Y Z
Symmetrically, you can use ^
to convert to upper case.
answered Oct 9 '17 at 12:37
choroba
24.5k34168
24.5k34168
Nice to know these features. Maybe, only bash man pages provides lot of advanced stuff.
â arunp
Oct 9 '17 at 12:46
add a comment |Â
Nice to know these features. Maybe, only bash man pages provides lot of advanced stuff.
â arunp
Oct 9 '17 at 12:46
Nice to know these features. Maybe, only bash man pages provides lot of advanced stuff.
â arunp
Oct 9 '17 at 12:46
Nice to know these features. Maybe, only bash man pages provides lot of advanced stuff.
â arunp
Oct 9 '17 at 12:46
add a comment |Â
up vote
2
down vote
man bash | grep -B1 -A10 ,,
$parameter,pattern
$parameter,,pattern
Case modification. This expansion modifies the case of alphaâÂÂ
betic characters in parameter. The pattern is expanded to proâÂÂ
duce a pattern just as in pathname expansion. Each character in
the expanded value of parameter is tested against pattern, and,
if it matches the pattern, its case is converted. The pattern
should not attempt to match more than one character. The ^
operator converts lowercase letters matching pattern to upperâÂÂ
case; the , operator converts matching uppercase letters to lowâÂÂ
ercase. The ^^ and ,, expansions convert each matched character
in the expanded value; the ^ and , expansions match and convert
only the first character in the expanded value. If pattern is
omitted, it is treated like a ?, which matches every character.
If parameter is @ or *, the case modification operation is
applied to each positional parameter in turn, and the expansion
is the resultant list. If parameter is an array variable subâÂÂ
scripted with @ or *, the case modification operation is applied
to each member of the array in turn, and the expansion is the
resultant list.
add a comment |Â
up vote
2
down vote
man bash | grep -B1 -A10 ,,
$parameter,pattern
$parameter,,pattern
Case modification. This expansion modifies the case of alphaâÂÂ
betic characters in parameter. The pattern is expanded to proâÂÂ
duce a pattern just as in pathname expansion. Each character in
the expanded value of parameter is tested against pattern, and,
if it matches the pattern, its case is converted. The pattern
should not attempt to match more than one character. The ^
operator converts lowercase letters matching pattern to upperâÂÂ
case; the , operator converts matching uppercase letters to lowâÂÂ
ercase. The ^^ and ,, expansions convert each matched character
in the expanded value; the ^ and , expansions match and convert
only the first character in the expanded value. If pattern is
omitted, it is treated like a ?, which matches every character.
If parameter is @ or *, the case modification operation is
applied to each positional parameter in turn, and the expansion
is the resultant list. If parameter is an array variable subâÂÂ
scripted with @ or *, the case modification operation is applied
to each member of the array in turn, and the expansion is the
resultant list.
add a comment |Â
up vote
2
down vote
up vote
2
down vote
man bash | grep -B1 -A10 ,,
$parameter,pattern
$parameter,,pattern
Case modification. This expansion modifies the case of alphaâÂÂ
betic characters in parameter. The pattern is expanded to proâÂÂ
duce a pattern just as in pathname expansion. Each character in
the expanded value of parameter is tested against pattern, and,
if it matches the pattern, its case is converted. The pattern
should not attempt to match more than one character. The ^
operator converts lowercase letters matching pattern to upperâÂÂ
case; the , operator converts matching uppercase letters to lowâÂÂ
ercase. The ^^ and ,, expansions convert each matched character
in the expanded value; the ^ and , expansions match and convert
only the first character in the expanded value. If pattern is
omitted, it is treated like a ?, which matches every character.
If parameter is @ or *, the case modification operation is
applied to each positional parameter in turn, and the expansion
is the resultant list. If parameter is an array variable subâÂÂ
scripted with @ or *, the case modification operation is applied
to each member of the array in turn, and the expansion is the
resultant list.
man bash | grep -B1 -A10 ,,
$parameter,pattern
$parameter,,pattern
Case modification. This expansion modifies the case of alphaâÂÂ
betic characters in parameter. The pattern is expanded to proâÂÂ
duce a pattern just as in pathname expansion. Each character in
the expanded value of parameter is tested against pattern, and,
if it matches the pattern, its case is converted. The pattern
should not attempt to match more than one character. The ^
operator converts lowercase letters matching pattern to upperâÂÂ
case; the , operator converts matching uppercase letters to lowâÂÂ
ercase. The ^^ and ,, expansions convert each matched character
in the expanded value; the ^ and , expansions match and convert
only the first character in the expanded value. If pattern is
omitted, it is treated like a ?, which matches every character.
If parameter is @ or *, the case modification operation is
applied to each positional parameter in turn, and the expansion
is the resultant list. If parameter is an array variable subâÂÂ
scripted with @ or *, the case modification operation is applied
to each member of the array in turn, and the expansion is the
resultant list.
answered Oct 9 '17 at 12:36
Tomasz
8,08752560
8,08752560
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%2f397002%2fwhat-does-it-mean-shell-read-command-line-arguments-1%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
1
Are you sure it's not
./script "$var1" "$var2"
instead?â Stéphane Chazelas
Oct 9 '17 at 13:05
@StéphaneChazelas - Its not "$var1" "$var2". Inside the script, while assigning the value there is double comma.
â arunp
Oct 10 '17 at 7:32