Use output of sed for a while read loop [duplicate]Reading lines in a file and avoiding lines with # with BashLoop through results of sedEmulate a do-while loop in Python?Syntax for a single-line Bash infinite while loopHow to count all the lines of code in a directory recursively?Looping through the content of a file in BashHow does “cat << EOF” work in bash?echo that outputs to stderrHow do I compare two string variables in an 'if' statement in Bash?How do I set a variable to the output of a command in Bash?How to change the output color of echo in LinuxLoop through an array of strings in Bash?

Social leper versus social leopard

How to make interviewee comfortable interviewing in lounge chairs

Can Northern Ireland's border issue be solved by repartition?

To what extent is it worthwhile to report check fraud / refund scams?

Resolving moral conflict

What are these pixel-level discolored specks? How can I fix it?

A drug that allows people to survive on less food

Are there non JavaScript ways to hide HTML source code?

Has my MacBook been hacked?

How to manage expenditure when billing cycles and paycheck cycles are not aligned?

How to deal with my team leader who keeps calling me about project updates even though I am on leave for personal reasons?

What is the meaning of "heutig" in this sentence?

Does Diablo III have a loot filter?

A high quality contribution but an annoying error is present in my published article

Is it impolite to ask for halal food when traveling to and in Thailand?

Writing a letter of recommendation for a mediocre student

What is the need of methods like GET and POST in the HTTP protocol?

In a folk jam session, when asked which key my non-transposing chromatic instrument (like a violin) is in, what do I answer?

Why are there two fundamental laws of logic?

reverse a list of generic type

Do we know the situation in Britain before Sealion (summer 1940)?

How can an attacker use robots.txt?

Meaning of 'ran' in German?

How use custom order in folder on Windows 7 and 10



Use output of sed for a while read loop [duplicate]


Reading lines in a file and avoiding lines with # with BashLoop through results of sedEmulate a do-while loop in Python?Syntax for a single-line Bash infinite while loopHow to count all the lines of code in a directory recursively?Looping through the content of a file in BashHow does “cat << EOF” work in bash?echo that outputs to stderrHow do I compare two string variables in an 'if' statement in Bash?How do I set a variable to the output of a command in Bash?How to change the output color of echo in LinuxLoop through an array of strings in Bash?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0
















This question already has an answer here:



  • Loop through results of sed

    2 answers



  • Reading lines in a file and avoiding lines with # with Bash

    10 answers



I want the while loop to ignore blank (empty) lines and lines that contain #



I tried including sed -e 's/#.*$//' -e '/^$/d' on the input file and piping this into the while loop. This did not work.



file=$(sed -e 's/#.*$//' -e '/^$/d' foo.txt)

while IFS=: read -r f1 f2 f3 f4; do

Command

done <"$file"









share|improve this question
















marked as duplicate by tripleee bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 28 at 16:23


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

























    0
















    This question already has an answer here:



    • Loop through results of sed

      2 answers



    • Reading lines in a file and avoiding lines with # with Bash

      10 answers



    I want the while loop to ignore blank (empty) lines and lines that contain #



    I tried including sed -e 's/#.*$//' -e '/^$/d' on the input file and piping this into the while loop. This did not work.



    file=$(sed -e 's/#.*$//' -e '/^$/d' foo.txt)

    while IFS=: read -r f1 f2 f3 f4; do

    Command

    done <"$file"









    share|improve this question
















    marked as duplicate by tripleee bash
    Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

    StackExchange.ready(function()
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function()
    $hover.showInfoMessage('',
    messageElement: $msg.clone().show(),
    transient: false,
    position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
    dismissable: false,
    relativeToBody: true
    );
    ,
    function()
    StackExchange.helpers.removeMessages();

    );
    );
    );
    Mar 28 at 16:23


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





















      0












      0








      0









      This question already has an answer here:



      • Loop through results of sed

        2 answers



      • Reading lines in a file and avoiding lines with # with Bash

        10 answers



      I want the while loop to ignore blank (empty) lines and lines that contain #



      I tried including sed -e 's/#.*$//' -e '/^$/d' on the input file and piping this into the while loop. This did not work.



      file=$(sed -e 's/#.*$//' -e '/^$/d' foo.txt)

      while IFS=: read -r f1 f2 f3 f4; do

      Command

      done <"$file"









      share|improve this question

















      This question already has an answer here:



      • Loop through results of sed

        2 answers



      • Reading lines in a file and avoiding lines with # with Bash

        10 answers



      I want the while loop to ignore blank (empty) lines and lines that contain #



      I tried including sed -e 's/#.*$//' -e '/^$/d' on the input file and piping this into the while loop. This did not work.



      file=$(sed -e 's/#.*$//' -e '/^$/d' foo.txt)

      while IFS=: read -r f1 f2 f3 f4; do

      Command

      done <"$file"




      This question already has an answer here:



      • Loop through results of sed

        2 answers



      • Reading lines in a file and avoiding lines with # with Bash

        10 answers







      linux bash while-loop






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 16:30









      Charles Duffy

      193k29 gold badges222 silver badges279 bronze badges




      193k29 gold badges222 silver badges279 bronze badges










      asked Mar 28 at 16:05









      KevinKevin

      185 bronze badges




      185 bronze badges





      marked as duplicate by tripleee bash
      Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

      StackExchange.ready(function()
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function()
      $hover.showInfoMessage('',
      messageElement: $msg.clone().show(),
      transient: false,
      position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
      dismissable: false,
      relativeToBody: true
      );
      ,
      function()
      StackExchange.helpers.removeMessages();

      );
      );
      );
      Mar 28 at 16:23


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











      marked as duplicate by tripleee bash
      Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

      StackExchange.ready(function()
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function()
      $hover.showInfoMessage('',
      messageElement: $msg.clone().show(),
      transient: false,
      position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
      dismissable: false,
      relativeToBody: true
      );
      ,
      function()
      StackExchange.helpers.removeMessages();

      );
      );
      );
      Mar 28 at 16:23


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









      marked as duplicate by tripleee bash
      Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

      StackExchange.ready(function()
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function()
      $hover.showInfoMessage('',
      messageElement: $msg.clone().show(),
      transient: false,
      position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
      dismissable: false,
      relativeToBody: true
      );
      ,
      function()
      StackExchange.helpers.removeMessages();

      );
      );
      );
      Mar 28 at 16:23


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
























          3 Answers
          3






          active

          oldest

          votes


















          4
















          You're trying to open that output as a filename, which it almost certainly isn't.



          Run sed in a subshell and redirect its output to while loop instead.



          while IFS=: read -r f1 f2 f3 f4; do
          # do something
          done < <(sed -e 's/#.*$//' -e '/^$/d' foo.txt)


          For anyone interested in how the syntax used in this answer works, see the bash-hackers' wiki on process substitution, and for why this syntax is better than sed ... | while read ..., see BashFAQ #24.






          share|improve this answer


































            0
















            You can use grep:



            grep -Ev '^s*$|^s*#' foo.txt | while IFS=: read -r f1 f2 f3 f4; do 
            Command
            done





            share|improve this answer

























            • Even grep -E isn't guaranteed to support s; only the regex syntax documented in the POSIX ERE standard is available across all platforms, and s -- like other backslash-sequence shorthand -- isn't there. To have guaranteed support on all POSIX platforms, use [[:space:]] instead.

              – Charles Duffy
              Mar 28 at 16:21












            • ...so, the use of grep doesn't fix anything (the old sed command worked fine), and (with the use of s) introduces portability issues; the use of a pipe does fix the OP's problem, but it fixes it in a way that introduces different bugs.

              – Charles Duffy
              Mar 28 at 16:22



















            -2
















            use grep -v:



            -v, --invert-match select non-matching lines





            share|improve this answer

























            • That certainly works, but the problem isn't with the sed code, it's with how they're getting its result into the while read loop. Thus, this answer replaces one piece of working code with a different piece of working code, but doesn't actually fix the bug the OP is asking about.

              – Charles Duffy
              Mar 28 at 16:13












            • If you read the title, then yes. But this is the first line of the post: "I want the while loop to ignore blank (empty) lines and lines that contain #" OP tried with sed, I'm suggesting to use grep instead.

              – Dimas
              Apr 4 at 17:08












            • Here's the thing, though -- the thing the OP tried with sed works fine. You're suggesting that they change the part that already works, not the part that's broken. The bug isn't caused by file=$(sed -e 's/#.*$//' -e '/^$/d' foo.txt) doing something other than what the OP expects it to, so changing that line to file=$(grep -v '#|^$') or whatever doesn't fix it.

              – Charles Duffy
              Apr 4 at 17:12












            • ...instead, the problem is caused by <"$file" iterating over a file named by the output of their sed command, or your grep command; switching which of those two interchangable commands is used is irrelevant to whether they hit that issue unless the other, later code is fixed.

              – Charles Duffy
              Apr 4 at 17:15




















            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            4
















            You're trying to open that output as a filename, which it almost certainly isn't.



            Run sed in a subshell and redirect its output to while loop instead.



            while IFS=: read -r f1 f2 f3 f4; do
            # do something
            done < <(sed -e 's/#.*$//' -e '/^$/d' foo.txt)


            For anyone interested in how the syntax used in this answer works, see the bash-hackers' wiki on process substitution, and for why this syntax is better than sed ... | while read ..., see BashFAQ #24.






            share|improve this answer































              4
















              You're trying to open that output as a filename, which it almost certainly isn't.



              Run sed in a subshell and redirect its output to while loop instead.



              while IFS=: read -r f1 f2 f3 f4; do
              # do something
              done < <(sed -e 's/#.*$//' -e '/^$/d' foo.txt)


              For anyone interested in how the syntax used in this answer works, see the bash-hackers' wiki on process substitution, and for why this syntax is better than sed ... | while read ..., see BashFAQ #24.






              share|improve this answer





























                4














                4










                4









                You're trying to open that output as a filename, which it almost certainly isn't.



                Run sed in a subshell and redirect its output to while loop instead.



                while IFS=: read -r f1 f2 f3 f4; do
                # do something
                done < <(sed -e 's/#.*$//' -e '/^$/d' foo.txt)


                For anyone interested in how the syntax used in this answer works, see the bash-hackers' wiki on process substitution, and for why this syntax is better than sed ... | while read ..., see BashFAQ #24.






                share|improve this answer















                You're trying to open that output as a filename, which it almost certainly isn't.



                Run sed in a subshell and redirect its output to while loop instead.



                while IFS=: read -r f1 f2 f3 f4; do
                # do something
                done < <(sed -e 's/#.*$//' -e '/^$/d' foo.txt)


                For anyone interested in how the syntax used in this answer works, see the bash-hackers' wiki on process substitution, and for why this syntax is better than sed ... | while read ..., see BashFAQ #24.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 28 at 16:23









                Charles Duffy

                193k29 gold badges222 silver badges279 bronze badges




                193k29 gold badges222 silver badges279 bronze badges










                answered Mar 28 at 16:07









                oguz ismailoguz ismail

                12.8k7 gold badges19 silver badges37 bronze badges




                12.8k7 gold badges19 silver badges37 bronze badges


























                    0
















                    You can use grep:



                    grep -Ev '^s*$|^s*#' foo.txt | while IFS=: read -r f1 f2 f3 f4; do 
                    Command
                    done





                    share|improve this answer

























                    • Even grep -E isn't guaranteed to support s; only the regex syntax documented in the POSIX ERE standard is available across all platforms, and s -- like other backslash-sequence shorthand -- isn't there. To have guaranteed support on all POSIX platforms, use [[:space:]] instead.

                      – Charles Duffy
                      Mar 28 at 16:21












                    • ...so, the use of grep doesn't fix anything (the old sed command worked fine), and (with the use of s) introduces portability issues; the use of a pipe does fix the OP's problem, but it fixes it in a way that introduces different bugs.

                      – Charles Duffy
                      Mar 28 at 16:22
















                    0
















                    You can use grep:



                    grep -Ev '^s*$|^s*#' foo.txt | while IFS=: read -r f1 f2 f3 f4; do 
                    Command
                    done





                    share|improve this answer

























                    • Even grep -E isn't guaranteed to support s; only the regex syntax documented in the POSIX ERE standard is available across all platforms, and s -- like other backslash-sequence shorthand -- isn't there. To have guaranteed support on all POSIX platforms, use [[:space:]] instead.

                      – Charles Duffy
                      Mar 28 at 16:21












                    • ...so, the use of grep doesn't fix anything (the old sed command worked fine), and (with the use of s) introduces portability issues; the use of a pipe does fix the OP's problem, but it fixes it in a way that introduces different bugs.

                      – Charles Duffy
                      Mar 28 at 16:22














                    0














                    0










                    0









                    You can use grep:



                    grep -Ev '^s*$|^s*#' foo.txt | while IFS=: read -r f1 f2 f3 f4; do 
                    Command
                    done





                    share|improve this answer













                    You can use grep:



                    grep -Ev '^s*$|^s*#' foo.txt | while IFS=: read -r f1 f2 f3 f4; do 
                    Command
                    done






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Mar 28 at 16:18









                    accdiasaccdias

                    1,1079 silver badges14 bronze badges




                    1,1079 silver badges14 bronze badges















                    • Even grep -E isn't guaranteed to support s; only the regex syntax documented in the POSIX ERE standard is available across all platforms, and s -- like other backslash-sequence shorthand -- isn't there. To have guaranteed support on all POSIX platforms, use [[:space:]] instead.

                      – Charles Duffy
                      Mar 28 at 16:21












                    • ...so, the use of grep doesn't fix anything (the old sed command worked fine), and (with the use of s) introduces portability issues; the use of a pipe does fix the OP's problem, but it fixes it in a way that introduces different bugs.

                      – Charles Duffy
                      Mar 28 at 16:22


















                    • Even grep -E isn't guaranteed to support s; only the regex syntax documented in the POSIX ERE standard is available across all platforms, and s -- like other backslash-sequence shorthand -- isn't there. To have guaranteed support on all POSIX platforms, use [[:space:]] instead.

                      – Charles Duffy
                      Mar 28 at 16:21












                    • ...so, the use of grep doesn't fix anything (the old sed command worked fine), and (with the use of s) introduces portability issues; the use of a pipe does fix the OP's problem, but it fixes it in a way that introduces different bugs.

                      – Charles Duffy
                      Mar 28 at 16:22

















                    Even grep -E isn't guaranteed to support s; only the regex syntax documented in the POSIX ERE standard is available across all platforms, and s -- like other backslash-sequence shorthand -- isn't there. To have guaranteed support on all POSIX platforms, use [[:space:]] instead.

                    – Charles Duffy
                    Mar 28 at 16:21






                    Even grep -E isn't guaranteed to support s; only the regex syntax documented in the POSIX ERE standard is available across all platforms, and s -- like other backslash-sequence shorthand -- isn't there. To have guaranteed support on all POSIX platforms, use [[:space:]] instead.

                    – Charles Duffy
                    Mar 28 at 16:21














                    ...so, the use of grep doesn't fix anything (the old sed command worked fine), and (with the use of s) introduces portability issues; the use of a pipe does fix the OP's problem, but it fixes it in a way that introduces different bugs.

                    – Charles Duffy
                    Mar 28 at 16:22






                    ...so, the use of grep doesn't fix anything (the old sed command worked fine), and (with the use of s) introduces portability issues; the use of a pipe does fix the OP's problem, but it fixes it in a way that introduces different bugs.

                    – Charles Duffy
                    Mar 28 at 16:22












                    -2
















                    use grep -v:



                    -v, --invert-match select non-matching lines





                    share|improve this answer

























                    • That certainly works, but the problem isn't with the sed code, it's with how they're getting its result into the while read loop. Thus, this answer replaces one piece of working code with a different piece of working code, but doesn't actually fix the bug the OP is asking about.

                      – Charles Duffy
                      Mar 28 at 16:13












                    • If you read the title, then yes. But this is the first line of the post: "I want the while loop to ignore blank (empty) lines and lines that contain #" OP tried with sed, I'm suggesting to use grep instead.

                      – Dimas
                      Apr 4 at 17:08












                    • Here's the thing, though -- the thing the OP tried with sed works fine. You're suggesting that they change the part that already works, not the part that's broken. The bug isn't caused by file=$(sed -e 's/#.*$//' -e '/^$/d' foo.txt) doing something other than what the OP expects it to, so changing that line to file=$(grep -v '#|^$') or whatever doesn't fix it.

                      – Charles Duffy
                      Apr 4 at 17:12












                    • ...instead, the problem is caused by <"$file" iterating over a file named by the output of their sed command, or your grep command; switching which of those two interchangable commands is used is irrelevant to whether they hit that issue unless the other, later code is fixed.

                      – Charles Duffy
                      Apr 4 at 17:15
















                    -2
















                    use grep -v:



                    -v, --invert-match select non-matching lines





                    share|improve this answer

























                    • That certainly works, but the problem isn't with the sed code, it's with how they're getting its result into the while read loop. Thus, this answer replaces one piece of working code with a different piece of working code, but doesn't actually fix the bug the OP is asking about.

                      – Charles Duffy
                      Mar 28 at 16:13












                    • If you read the title, then yes. But this is the first line of the post: "I want the while loop to ignore blank (empty) lines and lines that contain #" OP tried with sed, I'm suggesting to use grep instead.

                      – Dimas
                      Apr 4 at 17:08












                    • Here's the thing, though -- the thing the OP tried with sed works fine. You're suggesting that they change the part that already works, not the part that's broken. The bug isn't caused by file=$(sed -e 's/#.*$//' -e '/^$/d' foo.txt) doing something other than what the OP expects it to, so changing that line to file=$(grep -v '#|^$') or whatever doesn't fix it.

                      – Charles Duffy
                      Apr 4 at 17:12












                    • ...instead, the problem is caused by <"$file" iterating over a file named by the output of their sed command, or your grep command; switching which of those two interchangable commands is used is irrelevant to whether they hit that issue unless the other, later code is fixed.

                      – Charles Duffy
                      Apr 4 at 17:15














                    -2














                    -2










                    -2









                    use grep -v:



                    -v, --invert-match select non-matching lines





                    share|improve this answer













                    use grep -v:



                    -v, --invert-match select non-matching lines






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Mar 28 at 16:10









                    DimasDimas

                    787 bronze badges




                    787 bronze badges















                    • That certainly works, but the problem isn't with the sed code, it's with how they're getting its result into the while read loop. Thus, this answer replaces one piece of working code with a different piece of working code, but doesn't actually fix the bug the OP is asking about.

                      – Charles Duffy
                      Mar 28 at 16:13












                    • If you read the title, then yes. But this is the first line of the post: "I want the while loop to ignore blank (empty) lines and lines that contain #" OP tried with sed, I'm suggesting to use grep instead.

                      – Dimas
                      Apr 4 at 17:08












                    • Here's the thing, though -- the thing the OP tried with sed works fine. You're suggesting that they change the part that already works, not the part that's broken. The bug isn't caused by file=$(sed -e 's/#.*$//' -e '/^$/d' foo.txt) doing something other than what the OP expects it to, so changing that line to file=$(grep -v '#|^$') or whatever doesn't fix it.

                      – Charles Duffy
                      Apr 4 at 17:12












                    • ...instead, the problem is caused by <"$file" iterating over a file named by the output of their sed command, or your grep command; switching which of those two interchangable commands is used is irrelevant to whether they hit that issue unless the other, later code is fixed.

                      – Charles Duffy
                      Apr 4 at 17:15


















                    • That certainly works, but the problem isn't with the sed code, it's with how they're getting its result into the while read loop. Thus, this answer replaces one piece of working code with a different piece of working code, but doesn't actually fix the bug the OP is asking about.

                      – Charles Duffy
                      Mar 28 at 16:13












                    • If you read the title, then yes. But this is the first line of the post: "I want the while loop to ignore blank (empty) lines and lines that contain #" OP tried with sed, I'm suggesting to use grep instead.

                      – Dimas
                      Apr 4 at 17:08












                    • Here's the thing, though -- the thing the OP tried with sed works fine. You're suggesting that they change the part that already works, not the part that's broken. The bug isn't caused by file=$(sed -e 's/#.*$//' -e '/^$/d' foo.txt) doing something other than what the OP expects it to, so changing that line to file=$(grep -v '#|^$') or whatever doesn't fix it.

                      – Charles Duffy
                      Apr 4 at 17:12












                    • ...instead, the problem is caused by <"$file" iterating over a file named by the output of their sed command, or your grep command; switching which of those two interchangable commands is used is irrelevant to whether they hit that issue unless the other, later code is fixed.

                      – Charles Duffy
                      Apr 4 at 17:15

















                    That certainly works, but the problem isn't with the sed code, it's with how they're getting its result into the while read loop. Thus, this answer replaces one piece of working code with a different piece of working code, but doesn't actually fix the bug the OP is asking about.

                    – Charles Duffy
                    Mar 28 at 16:13






                    That certainly works, but the problem isn't with the sed code, it's with how they're getting its result into the while read loop. Thus, this answer replaces one piece of working code with a different piece of working code, but doesn't actually fix the bug the OP is asking about.

                    – Charles Duffy
                    Mar 28 at 16:13














                    If you read the title, then yes. But this is the first line of the post: "I want the while loop to ignore blank (empty) lines and lines that contain #" OP tried with sed, I'm suggesting to use grep instead.

                    – Dimas
                    Apr 4 at 17:08






                    If you read the title, then yes. But this is the first line of the post: "I want the while loop to ignore blank (empty) lines and lines that contain #" OP tried with sed, I'm suggesting to use grep instead.

                    – Dimas
                    Apr 4 at 17:08














                    Here's the thing, though -- the thing the OP tried with sed works fine. You're suggesting that they change the part that already works, not the part that's broken. The bug isn't caused by file=$(sed -e 's/#.*$//' -e '/^$/d' foo.txt) doing something other than what the OP expects it to, so changing that line to file=$(grep -v '#|^$') or whatever doesn't fix it.

                    – Charles Duffy
                    Apr 4 at 17:12






                    Here's the thing, though -- the thing the OP tried with sed works fine. You're suggesting that they change the part that already works, not the part that's broken. The bug isn't caused by file=$(sed -e 's/#.*$//' -e '/^$/d' foo.txt) doing something other than what the OP expects it to, so changing that line to file=$(grep -v '#|^$') or whatever doesn't fix it.

                    – Charles Duffy
                    Apr 4 at 17:12














                    ...instead, the problem is caused by <"$file" iterating over a file named by the output of their sed command, or your grep command; switching which of those two interchangable commands is used is irrelevant to whether they hit that issue unless the other, later code is fixed.

                    – Charles Duffy
                    Apr 4 at 17:15






                    ...instead, the problem is caused by <"$file" iterating over a file named by the output of their sed command, or your grep command; switching which of those two interchangable commands is used is irrelevant to whether they hit that issue unless the other, later code is fixed.

                    – Charles Duffy
                    Apr 4 at 17:15




                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript