bad substitution running $ls … with bash

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
5
down vote

favorite
1












I got the following error:



./assemblyDB.116.las
test.sh: line 9: $ sed 's/.las//': bad substitution


and this is the script:



for filename in $(find . -type f -name "assemblyDB.*.las"); do
echo $filename
no=$ sed 's/.las//'
echo $no
done


Thank you in advance.







share|improve this question






















  • What are you trying to accomplish with the braces? Also quote your variables.
    – Jesse_b
    Feb 25 at 14:04















up vote
5
down vote

favorite
1












I got the following error:



./assemblyDB.116.las
test.sh: line 9: $ sed 's/.las//': bad substitution


and this is the script:



for filename in $(find . -type f -name "assemblyDB.*.las"); do
echo $filename
no=$ sed 's/.las//'
echo $no
done


Thank you in advance.







share|improve this question






















  • What are you trying to accomplish with the braces? Also quote your variables.
    – Jesse_b
    Feb 25 at 14:04













up vote
5
down vote

favorite
1









up vote
5
down vote

favorite
1






1





I got the following error:



./assemblyDB.116.las
test.sh: line 9: $ sed 's/.las//': bad substitution


and this is the script:



for filename in $(find . -type f -name "assemblyDB.*.las"); do
echo $filename
no=$ sed 's/.las//'
echo $no
done


Thank you in advance.







share|improve this question














I got the following error:



./assemblyDB.116.las
test.sh: line 9: $ sed 's/.las//': bad substitution


and this is the script:



for filename in $(find . -type f -name "assemblyDB.*.las"); do
echo $filename
no=$ sed 's/.las//'
echo $no
done


Thank you in advance.









share|improve this question













share|improve this question




share|improve this question








edited Feb 26 at 1:26









Charles Duffy

734413




734413










asked Feb 25 at 13:58









user977828

3401516




3401516











  • What are you trying to accomplish with the braces? Also quote your variables.
    – Jesse_b
    Feb 25 at 14:04

















  • What are you trying to accomplish with the braces? Also quote your variables.
    – Jesse_b
    Feb 25 at 14:04
















What are you trying to accomplish with the braces? Also quote your variables.
– Jesse_b
Feb 25 at 14:04





What are you trying to accomplish with the braces? Also quote your variables.
– Jesse_b
Feb 25 at 14:04











3 Answers
3






active

oldest

votes

















up vote
17
down vote













$ ... (curly braces) marks several sorts of parameter expansion, the simplest of which is just expanding the value of a variable. The stuff inside braces isn't a valid parameter name, or any other expansion, so the shell complains.



You seem to want command substitution instead, for that, the syntax is $( ... ) (regular parenthesis).



Also, the ls in ls $filename | sed... seems a bit unnecessary, the variable expands to your filename, and ls just passes it through. You could just use echo "$filename" | sed ... instead.



That said, you could do those modifications directly in the shell:



no=$filename/assemblyDB. # remove first match
no=$no/.las


or, using the standard operators:



no=$filename#assemblyDB. # remove from start of string
no=$no%.las # remove from end of string


If you do run sed, you may want to note that . matches any character in regular expressions, so it would be more correct to quote it with a backslash. Also you can give one sed instance both commands: sed -e 's/assemblyDB.//' -e 's/.las//'.



And then for filename in $(find . -type f -name "assemblyDB.*.las"); do has the issues of parsing ls, mostly the fact that whitespace and wildcards in the file names will break it. In ksh/Bash/zsh, you could do that whole loop in the shell:



shopt -s globstar # in Bash
for filename in **/assemblyDB.*.las; do
...





share|improve this answer


















  • 1




    @Jesse_b, yes, but if your shell has <<<, it probably has $var/pat/repl too. If you do run sed, you could just give both rules to one sed instance: sed -e 's/assemblyDB.//' -e 's/.las//'
    – ilkkachu
    Feb 25 at 14:22











  • Just wanted to point out UUOE ;)
    – Jesse_b
    Feb 25 at 14:28

















up vote
0
down vote













Command substitution (line 3)



for filename in $(find . -type f -name "assemblyDB.*.las"); do
echo $filename
no=$(ls $filename | sed 's/assemblyDB.//' | sed 's/.las//')
echo $no
done


is equivalent, as already pointed out, to (line 3, no ls)



for filename in $(find . -type f -name "assemblyDB.*.las"); do
echo $filename
no=$(echo $filename | sed 's/assemblyDB.//' | sed 's/.las//')
echo $no
done


or shorter (line 4 gone, now echo directly)



for filename in $(find . -type f -name "assemblyDB.*.las"); do
echo $filename
echo $filename | sed 's/assemblyDB.//' | sed 's/.las//'
done


and the sed command can be reduced to (line 3)



for filename in $(find . -type f -name "assemblyDB.*.las"); do
echo $filename
echo $filename | sed 's/assemblyDB.//;s/.las//'
done


or maybe extract the middle part with sed: (still line 3)



for filename in $(find . -type f -name "assemblyDB.*.las"); do
echo $filename
echo $filename | sed -r 's/.*assemblyDB.(.*).las/1/'"
done


now find-iterator instead of for-iterator: (line 1 to 3, 4 gone)



find . -type f -name "assemblyDB.*.las" -printf "%fn" -exec sh -c "
echo | sed -r 's/.*assemblyDB.(.*).las/1/'" ";"

assemblyDB.11.las
11
assemblyDB.9.las
9
assemblyDB.10.las
10


If your filenames are in such or a similar order, the following might work too:



for i in 8..12 ; do ls assemblyDB.$i.las && echo $i ; done 2>/dev/null

assemblyDB.9.las
9
assemblyDB.10.las
10
assemblyDB.11.las
11


(8 and 12 included, to demonstrate missing files in the sequence).






share|improve this answer



























    up vote
    -3
    down vote













    Instead of $ use backticks ` [The button below Escape on your keyboard.]






    share|improve this answer


















    • 2




      Please don't use backticks. Use command substitution. $( ... )
      – Jesse_b
      Feb 25 at 14:04










    • Can you explain why back ticks are bad?
      – Raja Nand Sharma
      Feb 25 at 14:06






    • 3




      They are outdated, they are hard to read, they don't nest, and they can always be replaced by parenthesis command substitution. Additionally they are hard to place into inline code blocks on most markdown languages :)
      – Jesse_b
      Feb 25 at 14:07











    • Yeah, that is right. But in regards to this question where did my answer go wrong??
      – Raja Nand Sharma
      Feb 25 at 14:10






    • 6




      You suggested using backticks.
      – Jesse_b
      Feb 25 at 14:10










    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%2f426458%2fbad-substitution-running-ls-sed-with-bash%23new-answer', 'question_page');

    );

    Post as a guest






























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    17
    down vote













    $ ... (curly braces) marks several sorts of parameter expansion, the simplest of which is just expanding the value of a variable. The stuff inside braces isn't a valid parameter name, or any other expansion, so the shell complains.



    You seem to want command substitution instead, for that, the syntax is $( ... ) (regular parenthesis).



    Also, the ls in ls $filename | sed... seems a bit unnecessary, the variable expands to your filename, and ls just passes it through. You could just use echo "$filename" | sed ... instead.



    That said, you could do those modifications directly in the shell:



    no=$filename/assemblyDB. # remove first match
    no=$no/.las


    or, using the standard operators:



    no=$filename#assemblyDB. # remove from start of string
    no=$no%.las # remove from end of string


    If you do run sed, you may want to note that . matches any character in regular expressions, so it would be more correct to quote it with a backslash. Also you can give one sed instance both commands: sed -e 's/assemblyDB.//' -e 's/.las//'.



    And then for filename in $(find . -type f -name "assemblyDB.*.las"); do has the issues of parsing ls, mostly the fact that whitespace and wildcards in the file names will break it. In ksh/Bash/zsh, you could do that whole loop in the shell:



    shopt -s globstar # in Bash
    for filename in **/assemblyDB.*.las; do
    ...





    share|improve this answer


















    • 1




      @Jesse_b, yes, but if your shell has <<<, it probably has $var/pat/repl too. If you do run sed, you could just give both rules to one sed instance: sed -e 's/assemblyDB.//' -e 's/.las//'
      – ilkkachu
      Feb 25 at 14:22











    • Just wanted to point out UUOE ;)
      – Jesse_b
      Feb 25 at 14:28














    up vote
    17
    down vote













    $ ... (curly braces) marks several sorts of parameter expansion, the simplest of which is just expanding the value of a variable. The stuff inside braces isn't a valid parameter name, or any other expansion, so the shell complains.



    You seem to want command substitution instead, for that, the syntax is $( ... ) (regular parenthesis).



    Also, the ls in ls $filename | sed... seems a bit unnecessary, the variable expands to your filename, and ls just passes it through. You could just use echo "$filename" | sed ... instead.



    That said, you could do those modifications directly in the shell:



    no=$filename/assemblyDB. # remove first match
    no=$no/.las


    or, using the standard operators:



    no=$filename#assemblyDB. # remove from start of string
    no=$no%.las # remove from end of string


    If you do run sed, you may want to note that . matches any character in regular expressions, so it would be more correct to quote it with a backslash. Also you can give one sed instance both commands: sed -e 's/assemblyDB.//' -e 's/.las//'.



    And then for filename in $(find . -type f -name "assemblyDB.*.las"); do has the issues of parsing ls, mostly the fact that whitespace and wildcards in the file names will break it. In ksh/Bash/zsh, you could do that whole loop in the shell:



    shopt -s globstar # in Bash
    for filename in **/assemblyDB.*.las; do
    ...





    share|improve this answer


















    • 1




      @Jesse_b, yes, but if your shell has <<<, it probably has $var/pat/repl too. If you do run sed, you could just give both rules to one sed instance: sed -e 's/assemblyDB.//' -e 's/.las//'
      – ilkkachu
      Feb 25 at 14:22











    • Just wanted to point out UUOE ;)
      – Jesse_b
      Feb 25 at 14:28












    up vote
    17
    down vote










    up vote
    17
    down vote









    $ ... (curly braces) marks several sorts of parameter expansion, the simplest of which is just expanding the value of a variable. The stuff inside braces isn't a valid parameter name, or any other expansion, so the shell complains.



    You seem to want command substitution instead, for that, the syntax is $( ... ) (regular parenthesis).



    Also, the ls in ls $filename | sed... seems a bit unnecessary, the variable expands to your filename, and ls just passes it through. You could just use echo "$filename" | sed ... instead.



    That said, you could do those modifications directly in the shell:



    no=$filename/assemblyDB. # remove first match
    no=$no/.las


    or, using the standard operators:



    no=$filename#assemblyDB. # remove from start of string
    no=$no%.las # remove from end of string


    If you do run sed, you may want to note that . matches any character in regular expressions, so it would be more correct to quote it with a backslash. Also you can give one sed instance both commands: sed -e 's/assemblyDB.//' -e 's/.las//'.



    And then for filename in $(find . -type f -name "assemblyDB.*.las"); do has the issues of parsing ls, mostly the fact that whitespace and wildcards in the file names will break it. In ksh/Bash/zsh, you could do that whole loop in the shell:



    shopt -s globstar # in Bash
    for filename in **/assemblyDB.*.las; do
    ...





    share|improve this answer














    $ ... (curly braces) marks several sorts of parameter expansion, the simplest of which is just expanding the value of a variable. The stuff inside braces isn't a valid parameter name, or any other expansion, so the shell complains.



    You seem to want command substitution instead, for that, the syntax is $( ... ) (regular parenthesis).



    Also, the ls in ls $filename | sed... seems a bit unnecessary, the variable expands to your filename, and ls just passes it through. You could just use echo "$filename" | sed ... instead.



    That said, you could do those modifications directly in the shell:



    no=$filename/assemblyDB. # remove first match
    no=$no/.las


    or, using the standard operators:



    no=$filename#assemblyDB. # remove from start of string
    no=$no%.las # remove from end of string


    If you do run sed, you may want to note that . matches any character in regular expressions, so it would be more correct to quote it with a backslash. Also you can give one sed instance both commands: sed -e 's/assemblyDB.//' -e 's/.las//'.



    And then for filename in $(find . -type f -name "assemblyDB.*.las"); do has the issues of parsing ls, mostly the fact that whitespace and wildcards in the file names will break it. In ksh/Bash/zsh, you could do that whole loop in the shell:



    shopt -s globstar # in Bash
    for filename in **/assemblyDB.*.las; do
    ...






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Feb 25 at 14:25

























    answered Feb 25 at 14:08









    ilkkachu

    49.3k672136




    49.3k672136







    • 1




      @Jesse_b, yes, but if your shell has <<<, it probably has $var/pat/repl too. If you do run sed, you could just give both rules to one sed instance: sed -e 's/assemblyDB.//' -e 's/.las//'
      – ilkkachu
      Feb 25 at 14:22











    • Just wanted to point out UUOE ;)
      – Jesse_b
      Feb 25 at 14:28












    • 1




      @Jesse_b, yes, but if your shell has <<<, it probably has $var/pat/repl too. If you do run sed, you could just give both rules to one sed instance: sed -e 's/assemblyDB.//' -e 's/.las//'
      – ilkkachu
      Feb 25 at 14:22











    • Just wanted to point out UUOE ;)
      – Jesse_b
      Feb 25 at 14:28







    1




    1




    @Jesse_b, yes, but if your shell has <<<, it probably has $var/pat/repl too. If you do run sed, you could just give both rules to one sed instance: sed -e 's/assemblyDB.//' -e 's/.las//'
    – ilkkachu
    Feb 25 at 14:22





    @Jesse_b, yes, but if your shell has <<<, it probably has $var/pat/repl too. If you do run sed, you could just give both rules to one sed instance: sed -e 's/assemblyDB.//' -e 's/.las//'
    – ilkkachu
    Feb 25 at 14:22













    Just wanted to point out UUOE ;)
    – Jesse_b
    Feb 25 at 14:28




    Just wanted to point out UUOE ;)
    – Jesse_b
    Feb 25 at 14:28












    up vote
    0
    down vote













    Command substitution (line 3)



    for filename in $(find . -type f -name "assemblyDB.*.las"); do
    echo $filename
    no=$(ls $filename | sed 's/assemblyDB.//' | sed 's/.las//')
    echo $no
    done


    is equivalent, as already pointed out, to (line 3, no ls)



    for filename in $(find . -type f -name "assemblyDB.*.las"); do
    echo $filename
    no=$(echo $filename | sed 's/assemblyDB.//' | sed 's/.las//')
    echo $no
    done


    or shorter (line 4 gone, now echo directly)



    for filename in $(find . -type f -name "assemblyDB.*.las"); do
    echo $filename
    echo $filename | sed 's/assemblyDB.//' | sed 's/.las//'
    done


    and the sed command can be reduced to (line 3)



    for filename in $(find . -type f -name "assemblyDB.*.las"); do
    echo $filename
    echo $filename | sed 's/assemblyDB.//;s/.las//'
    done


    or maybe extract the middle part with sed: (still line 3)



    for filename in $(find . -type f -name "assemblyDB.*.las"); do
    echo $filename
    echo $filename | sed -r 's/.*assemblyDB.(.*).las/1/'"
    done


    now find-iterator instead of for-iterator: (line 1 to 3, 4 gone)



    find . -type f -name "assemblyDB.*.las" -printf "%fn" -exec sh -c "
    echo | sed -r 's/.*assemblyDB.(.*).las/1/'" ";"

    assemblyDB.11.las
    11
    assemblyDB.9.las
    9
    assemblyDB.10.las
    10


    If your filenames are in such or a similar order, the following might work too:



    for i in 8..12 ; do ls assemblyDB.$i.las && echo $i ; done 2>/dev/null

    assemblyDB.9.las
    9
    assemblyDB.10.las
    10
    assemblyDB.11.las
    11


    (8 and 12 included, to demonstrate missing files in the sequence).






    share|improve this answer
























      up vote
      0
      down vote













      Command substitution (line 3)



      for filename in $(find . -type f -name "assemblyDB.*.las"); do
      echo $filename
      no=$(ls $filename | sed 's/assemblyDB.//' | sed 's/.las//')
      echo $no
      done


      is equivalent, as already pointed out, to (line 3, no ls)



      for filename in $(find . -type f -name "assemblyDB.*.las"); do
      echo $filename
      no=$(echo $filename | sed 's/assemblyDB.//' | sed 's/.las//')
      echo $no
      done


      or shorter (line 4 gone, now echo directly)



      for filename in $(find . -type f -name "assemblyDB.*.las"); do
      echo $filename
      echo $filename | sed 's/assemblyDB.//' | sed 's/.las//'
      done


      and the sed command can be reduced to (line 3)



      for filename in $(find . -type f -name "assemblyDB.*.las"); do
      echo $filename
      echo $filename | sed 's/assemblyDB.//;s/.las//'
      done


      or maybe extract the middle part with sed: (still line 3)



      for filename in $(find . -type f -name "assemblyDB.*.las"); do
      echo $filename
      echo $filename | sed -r 's/.*assemblyDB.(.*).las/1/'"
      done


      now find-iterator instead of for-iterator: (line 1 to 3, 4 gone)



      find . -type f -name "assemblyDB.*.las" -printf "%fn" -exec sh -c "
      echo | sed -r 's/.*assemblyDB.(.*).las/1/'" ";"

      assemblyDB.11.las
      11
      assemblyDB.9.las
      9
      assemblyDB.10.las
      10


      If your filenames are in such or a similar order, the following might work too:



      for i in 8..12 ; do ls assemblyDB.$i.las && echo $i ; done 2>/dev/null

      assemblyDB.9.las
      9
      assemblyDB.10.las
      10
      assemblyDB.11.las
      11


      (8 and 12 included, to demonstrate missing files in the sequence).






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        Command substitution (line 3)



        for filename in $(find . -type f -name "assemblyDB.*.las"); do
        echo $filename
        no=$(ls $filename | sed 's/assemblyDB.//' | sed 's/.las//')
        echo $no
        done


        is equivalent, as already pointed out, to (line 3, no ls)



        for filename in $(find . -type f -name "assemblyDB.*.las"); do
        echo $filename
        no=$(echo $filename | sed 's/assemblyDB.//' | sed 's/.las//')
        echo $no
        done


        or shorter (line 4 gone, now echo directly)



        for filename in $(find . -type f -name "assemblyDB.*.las"); do
        echo $filename
        echo $filename | sed 's/assemblyDB.//' | sed 's/.las//'
        done


        and the sed command can be reduced to (line 3)



        for filename in $(find . -type f -name "assemblyDB.*.las"); do
        echo $filename
        echo $filename | sed 's/assemblyDB.//;s/.las//'
        done


        or maybe extract the middle part with sed: (still line 3)



        for filename in $(find . -type f -name "assemblyDB.*.las"); do
        echo $filename
        echo $filename | sed -r 's/.*assemblyDB.(.*).las/1/'"
        done


        now find-iterator instead of for-iterator: (line 1 to 3, 4 gone)



        find . -type f -name "assemblyDB.*.las" -printf "%fn" -exec sh -c "
        echo | sed -r 's/.*assemblyDB.(.*).las/1/'" ";"

        assemblyDB.11.las
        11
        assemblyDB.9.las
        9
        assemblyDB.10.las
        10


        If your filenames are in such or a similar order, the following might work too:



        for i in 8..12 ; do ls assemblyDB.$i.las && echo $i ; done 2>/dev/null

        assemblyDB.9.las
        9
        assemblyDB.10.las
        10
        assemblyDB.11.las
        11


        (8 and 12 included, to demonstrate missing files in the sequence).






        share|improve this answer












        Command substitution (line 3)



        for filename in $(find . -type f -name "assemblyDB.*.las"); do
        echo $filename
        no=$(ls $filename | sed 's/assemblyDB.//' | sed 's/.las//')
        echo $no
        done


        is equivalent, as already pointed out, to (line 3, no ls)



        for filename in $(find . -type f -name "assemblyDB.*.las"); do
        echo $filename
        no=$(echo $filename | sed 's/assemblyDB.//' | sed 's/.las//')
        echo $no
        done


        or shorter (line 4 gone, now echo directly)



        for filename in $(find . -type f -name "assemblyDB.*.las"); do
        echo $filename
        echo $filename | sed 's/assemblyDB.//' | sed 's/.las//'
        done


        and the sed command can be reduced to (line 3)



        for filename in $(find . -type f -name "assemblyDB.*.las"); do
        echo $filename
        echo $filename | sed 's/assemblyDB.//;s/.las//'
        done


        or maybe extract the middle part with sed: (still line 3)



        for filename in $(find . -type f -name "assemblyDB.*.las"); do
        echo $filename
        echo $filename | sed -r 's/.*assemblyDB.(.*).las/1/'"
        done


        now find-iterator instead of for-iterator: (line 1 to 3, 4 gone)



        find . -type f -name "assemblyDB.*.las" -printf "%fn" -exec sh -c "
        echo | sed -r 's/.*assemblyDB.(.*).las/1/'" ";"

        assemblyDB.11.las
        11
        assemblyDB.9.las
        9
        assemblyDB.10.las
        10


        If your filenames are in such or a similar order, the following might work too:



        for i in 8..12 ; do ls assemblyDB.$i.las && echo $i ; done 2>/dev/null

        assemblyDB.9.las
        9
        assemblyDB.10.las
        10
        assemblyDB.11.las
        11


        (8 and 12 included, to demonstrate missing files in the sequence).







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 26 at 2:46









        user unknown

        6,95412148




        6,95412148




















            up vote
            -3
            down vote













            Instead of $ use backticks ` [The button below Escape on your keyboard.]






            share|improve this answer


















            • 2




              Please don't use backticks. Use command substitution. $( ... )
              – Jesse_b
              Feb 25 at 14:04










            • Can you explain why back ticks are bad?
              – Raja Nand Sharma
              Feb 25 at 14:06






            • 3




              They are outdated, they are hard to read, they don't nest, and they can always be replaced by parenthesis command substitution. Additionally they are hard to place into inline code blocks on most markdown languages :)
              – Jesse_b
              Feb 25 at 14:07











            • Yeah, that is right. But in regards to this question where did my answer go wrong??
              – Raja Nand Sharma
              Feb 25 at 14:10






            • 6




              You suggested using backticks.
              – Jesse_b
              Feb 25 at 14:10














            up vote
            -3
            down vote













            Instead of $ use backticks ` [The button below Escape on your keyboard.]






            share|improve this answer


















            • 2




              Please don't use backticks. Use command substitution. $( ... )
              – Jesse_b
              Feb 25 at 14:04










            • Can you explain why back ticks are bad?
              – Raja Nand Sharma
              Feb 25 at 14:06






            • 3




              They are outdated, they are hard to read, they don't nest, and they can always be replaced by parenthesis command substitution. Additionally they are hard to place into inline code blocks on most markdown languages :)
              – Jesse_b
              Feb 25 at 14:07











            • Yeah, that is right. But in regards to this question where did my answer go wrong??
              – Raja Nand Sharma
              Feb 25 at 14:10






            • 6




              You suggested using backticks.
              – Jesse_b
              Feb 25 at 14:10












            up vote
            -3
            down vote










            up vote
            -3
            down vote









            Instead of $ use backticks ` [The button below Escape on your keyboard.]






            share|improve this answer














            Instead of $ use backticks ` [The button below Escape on your keyboard.]







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 25 at 14:11









            Jesse_b

            10.4k22658




            10.4k22658










            answered Feb 25 at 14:04









            Raja Nand Sharma

            11




            11







            • 2




              Please don't use backticks. Use command substitution. $( ... )
              – Jesse_b
              Feb 25 at 14:04










            • Can you explain why back ticks are bad?
              – Raja Nand Sharma
              Feb 25 at 14:06






            • 3




              They are outdated, they are hard to read, they don't nest, and they can always be replaced by parenthesis command substitution. Additionally they are hard to place into inline code blocks on most markdown languages :)
              – Jesse_b
              Feb 25 at 14:07











            • Yeah, that is right. But in regards to this question where did my answer go wrong??
              – Raja Nand Sharma
              Feb 25 at 14:10






            • 6




              You suggested using backticks.
              – Jesse_b
              Feb 25 at 14:10












            • 2




              Please don't use backticks. Use command substitution. $( ... )
              – Jesse_b
              Feb 25 at 14:04










            • Can you explain why back ticks are bad?
              – Raja Nand Sharma
              Feb 25 at 14:06






            • 3




              They are outdated, they are hard to read, they don't nest, and they can always be replaced by parenthesis command substitution. Additionally they are hard to place into inline code blocks on most markdown languages :)
              – Jesse_b
              Feb 25 at 14:07











            • Yeah, that is right. But in regards to this question where did my answer go wrong??
              – Raja Nand Sharma
              Feb 25 at 14:10






            • 6




              You suggested using backticks.
              – Jesse_b
              Feb 25 at 14:10







            2




            2




            Please don't use backticks. Use command substitution. $( ... )
            – Jesse_b
            Feb 25 at 14:04




            Please don't use backticks. Use command substitution. $( ... )
            – Jesse_b
            Feb 25 at 14:04












            Can you explain why back ticks are bad?
            – Raja Nand Sharma
            Feb 25 at 14:06




            Can you explain why back ticks are bad?
            – Raja Nand Sharma
            Feb 25 at 14:06




            3




            3




            They are outdated, they are hard to read, they don't nest, and they can always be replaced by parenthesis command substitution. Additionally they are hard to place into inline code blocks on most markdown languages :)
            – Jesse_b
            Feb 25 at 14:07





            They are outdated, they are hard to read, they don't nest, and they can always be replaced by parenthesis command substitution. Additionally they are hard to place into inline code blocks on most markdown languages :)
            – Jesse_b
            Feb 25 at 14:07













            Yeah, that is right. But in regards to this question where did my answer go wrong??
            – Raja Nand Sharma
            Feb 25 at 14:10




            Yeah, that is right. But in regards to this question where did my answer go wrong??
            – Raja Nand Sharma
            Feb 25 at 14:10




            6




            6




            You suggested using backticks.
            – Jesse_b
            Feb 25 at 14:10




            You suggested using backticks.
            – Jesse_b
            Feb 25 at 14:10












             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f426458%2fbad-substitution-running-ls-sed-with-bash%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?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay