what does it mean shell read command line arguments $1,,

The name of the pictureThe name of the pictureThe name of the pictureClash 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









share|improve this question



















  • 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














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









share|improve this question



















  • 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












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









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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












  • 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










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.






share|improve this answer




















  • Nice to know these features. Maybe, only bash man pages provides lot of advanced stuff.
    – arunp
    Oct 9 '17 at 12:46

















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.





share|improve this answer




















    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',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    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






























    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.






    share|improve this answer




















    • Nice to know these features. Maybe, only bash man pages provides lot of advanced stuff.
      – arunp
      Oct 9 '17 at 12:46














    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.






    share|improve this answer




















    • Nice to know these features. Maybe, only bash man pages provides lot of advanced stuff.
      – arunp
      Oct 9 '17 at 12:46












    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.






    share|improve this answer












    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.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    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
















    • 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












    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.





    share|improve this answer
























      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.





      share|improve this answer






















        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.





        share|improve this answer












        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.






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 9 '17 at 12:36









        Tomasz

        8,08752560




        8,08752560



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            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













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?