How do I read line by line in a file using while loop, and in each iteration, grep each line to compare to a...











up vote
2
down vote

favorite












I have a file called abc.txt with the contents as follows:



1: It is a shell script
2: There are few lines in this file
3: I am good with programming in C, but beginner in shell
4: We are going towards end of file
5: END OF FILE


I want to read each of the file iteratively, and in each iteration I want to compare the line with "I am good with programming in C, but beginner in shell", and then do some processing.



Any help would be greatly appreciated. Thanks!










share|improve this question


























    up vote
    2
    down vote

    favorite












    I have a file called abc.txt with the contents as follows:



    1: It is a shell script
    2: There are few lines in this file
    3: I am good with programming in C, but beginner in shell
    4: We are going towards end of file
    5: END OF FILE


    I want to read each of the file iteratively, and in each iteration I want to compare the line with "I am good with programming in C, but beginner in shell", and then do some processing.



    Any help would be greatly appreciated. Thanks!










    share|improve this question
























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I have a file called abc.txt with the contents as follows:



      1: It is a shell script
      2: There are few lines in this file
      3: I am good with programming in C, but beginner in shell
      4: We are going towards end of file
      5: END OF FILE


      I want to read each of the file iteratively, and in each iteration I want to compare the line with "I am good with programming in C, but beginner in shell", and then do some processing.



      Any help would be greatly appreciated. Thanks!










      share|improve this question













      I have a file called abc.txt with the contents as follows:



      1: It is a shell script
      2: There are few lines in this file
      3: I am good with programming in C, but beginner in shell
      4: We are going towards end of file
      5: END OF FILE


      I want to read each of the file iteratively, and in each iteration I want to compare the line with "I am good with programming in C, but beginner in shell", and then do some processing.



      Any help would be greatly appreciated. Thanks!







      command-line grep






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 4 at 17:32









      ShellyBelly

      656




      656






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          7
          down vote













          Using a shell loop is unnecessary, as grep already iterates over lines:



          grep '^[0-9]:  I am good with programming in C, but beginner in shell' input.txt


          If there's a matching line, it will be printed. [0-9] defines range of characters that will be matched. We can also extend that to longer numbers [0-9]*: (and I think with perl regex -P option that could be done as [0-9]+:).



          If a shell loop is really necessary, we can use case statement for pattern matching



          while IFS= read -r line; do
          case $line in
          *": I am good with programming in C") echo "Matched: $line";;
          esac
          done < input.xt





          share|improve this answer























          • ^[0-9]: isn't needed at all either, it seems.
            – Michael Hampton
            Dec 5 at 3:01










          • @MichaelHampton To be fair, yes, in this case not needed at all - user can get away with just .*I am good with programming in C or just pick a unique word from that sentence. Or even grep 'C.*shell'. There's no and statement in grep, but we could get away with grep 'shell' | grep 'C' . Of course, everything depends on user's input data to construct a proper regex pattern.
            – Sergiy Kolodyazhnyy
            Dec 5 at 4:48










          • @SergiyKolodyazhnyy, See this question, this is exactly what I need. Please help! askubuntu.com/questions/1098503/…
            – ShellyBelly
            Dec 5 at 20:35




















          up vote
          7
          down vote













          Try this sample code to help identify and modify to suit your needs:



          #!/usr/bin/env bash
          set -e
          set -x

          while read -r linenum line
          do
          if [ "$line" = "I am good with programming in C, but beginner in shell" ]
          then
          # Process things here
          echo "same"
          fi
          done < "$1"


          Usage:





          • Make executable:



            chmod +x script.sh



          • Place script in any folder then run script by passing a file to it:



            ./script.sh /path/to/data.txt



          Info:





          • -r: Option passed to read command prevents backslash escapes from being interpreted.


          • set -e: Bash option to stop script on first error.


          • set -x: Bash option used to debug the scrtip.


          • "$1": The file variable passed to the script in this case data.txt


          • linenum: variable that holds the line numbers when bash splits the read lines into two variables while the other is passed in via the lin variable.






          share|improve this answer



















          • 1




            @George So you're using -d" " to split on whitespace and cut all lines starting from the second one. I'd suggest another way: while IFS= read -r linenum line. The shell will perform wordsplitting on the input line and place first item ( line numbers ) into linenum variable, but all other things will go into line variable. Aside from other things, case statement can be used as alternative to [[ comparison.
            – Sergiy Kolodyazhnyy
            Dec 4 at 18:44










          • Can I implement this script in #!/bin/sh ?
            – ShellyBelly
            Dec 4 at 18:49










          • @AkshayNandi Yes, but you need to change [[ to [ because [[ is specific to bash. See my answer for portable solution
            – Sergiy Kolodyazhnyy
            Dec 4 at 18:52










          • @SergiyKolodyazhnyy I tried that it didn't do so on the word splitting.
            – George Udosen
            Dec 4 at 19:36






          • 1




            @GeorgeUdosen Ah, yes, I found the issue - it's because of IFS=. It unsets the variable temporarily, which is what is used for word splitting. IFS defaults to whitespace,tab,and newline. And it's a habit, but also for a good reason, to unset it - if there's a leading whitespace ( line starts with space ) it would be gone without IFS=
            – Sergiy Kolodyazhnyy
            Dec 5 at 0:07











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1098445%2fhow-do-i-read-line-by-line-in-a-file-using-while-loop-and-in-each-iteration-gr%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          7
          down vote













          Using a shell loop is unnecessary, as grep already iterates over lines:



          grep '^[0-9]:  I am good with programming in C, but beginner in shell' input.txt


          If there's a matching line, it will be printed. [0-9] defines range of characters that will be matched. We can also extend that to longer numbers [0-9]*: (and I think with perl regex -P option that could be done as [0-9]+:).



          If a shell loop is really necessary, we can use case statement for pattern matching



          while IFS= read -r line; do
          case $line in
          *": I am good with programming in C") echo "Matched: $line";;
          esac
          done < input.xt





          share|improve this answer























          • ^[0-9]: isn't needed at all either, it seems.
            – Michael Hampton
            Dec 5 at 3:01










          • @MichaelHampton To be fair, yes, in this case not needed at all - user can get away with just .*I am good with programming in C or just pick a unique word from that sentence. Or even grep 'C.*shell'. There's no and statement in grep, but we could get away with grep 'shell' | grep 'C' . Of course, everything depends on user's input data to construct a proper regex pattern.
            – Sergiy Kolodyazhnyy
            Dec 5 at 4:48










          • @SergiyKolodyazhnyy, See this question, this is exactly what I need. Please help! askubuntu.com/questions/1098503/…
            – ShellyBelly
            Dec 5 at 20:35

















          up vote
          7
          down vote













          Using a shell loop is unnecessary, as grep already iterates over lines:



          grep '^[0-9]:  I am good with programming in C, but beginner in shell' input.txt


          If there's a matching line, it will be printed. [0-9] defines range of characters that will be matched. We can also extend that to longer numbers [0-9]*: (and I think with perl regex -P option that could be done as [0-9]+:).



          If a shell loop is really necessary, we can use case statement for pattern matching



          while IFS= read -r line; do
          case $line in
          *": I am good with programming in C") echo "Matched: $line";;
          esac
          done < input.xt





          share|improve this answer























          • ^[0-9]: isn't needed at all either, it seems.
            – Michael Hampton
            Dec 5 at 3:01










          • @MichaelHampton To be fair, yes, in this case not needed at all - user can get away with just .*I am good with programming in C or just pick a unique word from that sentence. Or even grep 'C.*shell'. There's no and statement in grep, but we could get away with grep 'shell' | grep 'C' . Of course, everything depends on user's input data to construct a proper regex pattern.
            – Sergiy Kolodyazhnyy
            Dec 5 at 4:48










          • @SergiyKolodyazhnyy, See this question, this is exactly what I need. Please help! askubuntu.com/questions/1098503/…
            – ShellyBelly
            Dec 5 at 20:35















          up vote
          7
          down vote










          up vote
          7
          down vote









          Using a shell loop is unnecessary, as grep already iterates over lines:



          grep '^[0-9]:  I am good with programming in C, but beginner in shell' input.txt


          If there's a matching line, it will be printed. [0-9] defines range of characters that will be matched. We can also extend that to longer numbers [0-9]*: (and I think with perl regex -P option that could be done as [0-9]+:).



          If a shell loop is really necessary, we can use case statement for pattern matching



          while IFS= read -r line; do
          case $line in
          *": I am good with programming in C") echo "Matched: $line";;
          esac
          done < input.xt





          share|improve this answer














          Using a shell loop is unnecessary, as grep already iterates over lines:



          grep '^[0-9]:  I am good with programming in C, but beginner in shell' input.txt


          If there's a matching line, it will be printed. [0-9] defines range of characters that will be matched. We can also extend that to longer numbers [0-9]*: (and I think with perl regex -P option that could be done as [0-9]+:).



          If a shell loop is really necessary, we can use case statement for pattern matching



          while IFS= read -r line; do
          case $line in
          *": I am good with programming in C") echo "Matched: $line";;
          esac
          done < input.xt






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 4 at 19:21









          dessert

          21.7k55896




          21.7k55896










          answered Dec 4 at 18:52









          Sergiy Kolodyazhnyy

          68.9k9143303




          68.9k9143303












          • ^[0-9]: isn't needed at all either, it seems.
            – Michael Hampton
            Dec 5 at 3:01










          • @MichaelHampton To be fair, yes, in this case not needed at all - user can get away with just .*I am good with programming in C or just pick a unique word from that sentence. Or even grep 'C.*shell'. There's no and statement in grep, but we could get away with grep 'shell' | grep 'C' . Of course, everything depends on user's input data to construct a proper regex pattern.
            – Sergiy Kolodyazhnyy
            Dec 5 at 4:48










          • @SergiyKolodyazhnyy, See this question, this is exactly what I need. Please help! askubuntu.com/questions/1098503/…
            – ShellyBelly
            Dec 5 at 20:35




















          • ^[0-9]: isn't needed at all either, it seems.
            – Michael Hampton
            Dec 5 at 3:01










          • @MichaelHampton To be fair, yes, in this case not needed at all - user can get away with just .*I am good with programming in C or just pick a unique word from that sentence. Or even grep 'C.*shell'. There's no and statement in grep, but we could get away with grep 'shell' | grep 'C' . Of course, everything depends on user's input data to construct a proper regex pattern.
            – Sergiy Kolodyazhnyy
            Dec 5 at 4:48










          • @SergiyKolodyazhnyy, See this question, this is exactly what I need. Please help! askubuntu.com/questions/1098503/…
            – ShellyBelly
            Dec 5 at 20:35


















          ^[0-9]: isn't needed at all either, it seems.
          – Michael Hampton
          Dec 5 at 3:01




          ^[0-9]: isn't needed at all either, it seems.
          – Michael Hampton
          Dec 5 at 3:01












          @MichaelHampton To be fair, yes, in this case not needed at all - user can get away with just .*I am good with programming in C or just pick a unique word from that sentence. Or even grep 'C.*shell'. There's no and statement in grep, but we could get away with grep 'shell' | grep 'C' . Of course, everything depends on user's input data to construct a proper regex pattern.
          – Sergiy Kolodyazhnyy
          Dec 5 at 4:48




          @MichaelHampton To be fair, yes, in this case not needed at all - user can get away with just .*I am good with programming in C or just pick a unique word from that sentence. Or even grep 'C.*shell'. There's no and statement in grep, but we could get away with grep 'shell' | grep 'C' . Of course, everything depends on user's input data to construct a proper regex pattern.
          – Sergiy Kolodyazhnyy
          Dec 5 at 4:48












          @SergiyKolodyazhnyy, See this question, this is exactly what I need. Please help! askubuntu.com/questions/1098503/…
          – ShellyBelly
          Dec 5 at 20:35






          @SergiyKolodyazhnyy, See this question, this is exactly what I need. Please help! askubuntu.com/questions/1098503/…
          – ShellyBelly
          Dec 5 at 20:35














          up vote
          7
          down vote













          Try this sample code to help identify and modify to suit your needs:



          #!/usr/bin/env bash
          set -e
          set -x

          while read -r linenum line
          do
          if [ "$line" = "I am good with programming in C, but beginner in shell" ]
          then
          # Process things here
          echo "same"
          fi
          done < "$1"


          Usage:





          • Make executable:



            chmod +x script.sh



          • Place script in any folder then run script by passing a file to it:



            ./script.sh /path/to/data.txt



          Info:





          • -r: Option passed to read command prevents backslash escapes from being interpreted.


          • set -e: Bash option to stop script on first error.


          • set -x: Bash option used to debug the scrtip.


          • "$1": The file variable passed to the script in this case data.txt


          • linenum: variable that holds the line numbers when bash splits the read lines into two variables while the other is passed in via the lin variable.






          share|improve this answer



















          • 1




            @George So you're using -d" " to split on whitespace and cut all lines starting from the second one. I'd suggest another way: while IFS= read -r linenum line. The shell will perform wordsplitting on the input line and place first item ( line numbers ) into linenum variable, but all other things will go into line variable. Aside from other things, case statement can be used as alternative to [[ comparison.
            – Sergiy Kolodyazhnyy
            Dec 4 at 18:44










          • Can I implement this script in #!/bin/sh ?
            – ShellyBelly
            Dec 4 at 18:49










          • @AkshayNandi Yes, but you need to change [[ to [ because [[ is specific to bash. See my answer for portable solution
            – Sergiy Kolodyazhnyy
            Dec 4 at 18:52










          • @SergiyKolodyazhnyy I tried that it didn't do so on the word splitting.
            – George Udosen
            Dec 4 at 19:36






          • 1




            @GeorgeUdosen Ah, yes, I found the issue - it's because of IFS=. It unsets the variable temporarily, which is what is used for word splitting. IFS defaults to whitespace,tab,and newline. And it's a habit, but also for a good reason, to unset it - if there's a leading whitespace ( line starts with space ) it would be gone without IFS=
            – Sergiy Kolodyazhnyy
            Dec 5 at 0:07















          up vote
          7
          down vote













          Try this sample code to help identify and modify to suit your needs:



          #!/usr/bin/env bash
          set -e
          set -x

          while read -r linenum line
          do
          if [ "$line" = "I am good with programming in C, but beginner in shell" ]
          then
          # Process things here
          echo "same"
          fi
          done < "$1"


          Usage:





          • Make executable:



            chmod +x script.sh



          • Place script in any folder then run script by passing a file to it:



            ./script.sh /path/to/data.txt



          Info:





          • -r: Option passed to read command prevents backslash escapes from being interpreted.


          • set -e: Bash option to stop script on first error.


          • set -x: Bash option used to debug the scrtip.


          • "$1": The file variable passed to the script in this case data.txt


          • linenum: variable that holds the line numbers when bash splits the read lines into two variables while the other is passed in via the lin variable.






          share|improve this answer



















          • 1




            @George So you're using -d" " to split on whitespace and cut all lines starting from the second one. I'd suggest another way: while IFS= read -r linenum line. The shell will perform wordsplitting on the input line and place first item ( line numbers ) into linenum variable, but all other things will go into line variable. Aside from other things, case statement can be used as alternative to [[ comparison.
            – Sergiy Kolodyazhnyy
            Dec 4 at 18:44










          • Can I implement this script in #!/bin/sh ?
            – ShellyBelly
            Dec 4 at 18:49










          • @AkshayNandi Yes, but you need to change [[ to [ because [[ is specific to bash. See my answer for portable solution
            – Sergiy Kolodyazhnyy
            Dec 4 at 18:52










          • @SergiyKolodyazhnyy I tried that it didn't do so on the word splitting.
            – George Udosen
            Dec 4 at 19:36






          • 1




            @GeorgeUdosen Ah, yes, I found the issue - it's because of IFS=. It unsets the variable temporarily, which is what is used for word splitting. IFS defaults to whitespace,tab,and newline. And it's a habit, but also for a good reason, to unset it - if there's a leading whitespace ( line starts with space ) it would be gone without IFS=
            – Sergiy Kolodyazhnyy
            Dec 5 at 0:07













          up vote
          7
          down vote










          up vote
          7
          down vote









          Try this sample code to help identify and modify to suit your needs:



          #!/usr/bin/env bash
          set -e
          set -x

          while read -r linenum line
          do
          if [ "$line" = "I am good with programming in C, but beginner in shell" ]
          then
          # Process things here
          echo "same"
          fi
          done < "$1"


          Usage:





          • Make executable:



            chmod +x script.sh



          • Place script in any folder then run script by passing a file to it:



            ./script.sh /path/to/data.txt



          Info:





          • -r: Option passed to read command prevents backslash escapes from being interpreted.


          • set -e: Bash option to stop script on first error.


          • set -x: Bash option used to debug the scrtip.


          • "$1": The file variable passed to the script in this case data.txt


          • linenum: variable that holds the line numbers when bash splits the read lines into two variables while the other is passed in via the lin variable.






          share|improve this answer














          Try this sample code to help identify and modify to suit your needs:



          #!/usr/bin/env bash
          set -e
          set -x

          while read -r linenum line
          do
          if [ "$line" = "I am good with programming in C, but beginner in shell" ]
          then
          # Process things here
          echo "same"
          fi
          done < "$1"


          Usage:





          • Make executable:



            chmod +x script.sh



          • Place script in any folder then run script by passing a file to it:



            ./script.sh /path/to/data.txt



          Info:





          • -r: Option passed to read command prevents backslash escapes from being interpreted.


          • set -e: Bash option to stop script on first error.


          • set -x: Bash option used to debug the scrtip.


          • "$1": The file variable passed to the script in this case data.txt


          • linenum: variable that holds the line numbers when bash splits the read lines into two variables while the other is passed in via the lin variable.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 5 at 7:42

























          answered Dec 4 at 18:03









          George Udosen

          19.1k94266




          19.1k94266








          • 1




            @George So you're using -d" " to split on whitespace and cut all lines starting from the second one. I'd suggest another way: while IFS= read -r linenum line. The shell will perform wordsplitting on the input line and place first item ( line numbers ) into linenum variable, but all other things will go into line variable. Aside from other things, case statement can be used as alternative to [[ comparison.
            – Sergiy Kolodyazhnyy
            Dec 4 at 18:44










          • Can I implement this script in #!/bin/sh ?
            – ShellyBelly
            Dec 4 at 18:49










          • @AkshayNandi Yes, but you need to change [[ to [ because [[ is specific to bash. See my answer for portable solution
            – Sergiy Kolodyazhnyy
            Dec 4 at 18:52










          • @SergiyKolodyazhnyy I tried that it didn't do so on the word splitting.
            – George Udosen
            Dec 4 at 19:36






          • 1




            @GeorgeUdosen Ah, yes, I found the issue - it's because of IFS=. It unsets the variable temporarily, which is what is used for word splitting. IFS defaults to whitespace,tab,and newline. And it's a habit, but also for a good reason, to unset it - if there's a leading whitespace ( line starts with space ) it would be gone without IFS=
            – Sergiy Kolodyazhnyy
            Dec 5 at 0:07














          • 1




            @George So you're using -d" " to split on whitespace and cut all lines starting from the second one. I'd suggest another way: while IFS= read -r linenum line. The shell will perform wordsplitting on the input line and place first item ( line numbers ) into linenum variable, but all other things will go into line variable. Aside from other things, case statement can be used as alternative to [[ comparison.
            – Sergiy Kolodyazhnyy
            Dec 4 at 18:44










          • Can I implement this script in #!/bin/sh ?
            – ShellyBelly
            Dec 4 at 18:49










          • @AkshayNandi Yes, but you need to change [[ to [ because [[ is specific to bash. See my answer for portable solution
            – Sergiy Kolodyazhnyy
            Dec 4 at 18:52










          • @SergiyKolodyazhnyy I tried that it didn't do so on the word splitting.
            – George Udosen
            Dec 4 at 19:36






          • 1




            @GeorgeUdosen Ah, yes, I found the issue - it's because of IFS=. It unsets the variable temporarily, which is what is used for word splitting. IFS defaults to whitespace,tab,and newline. And it's a habit, but also for a good reason, to unset it - if there's a leading whitespace ( line starts with space ) it would be gone without IFS=
            – Sergiy Kolodyazhnyy
            Dec 5 at 0:07








          1




          1




          @George So you're using -d" " to split on whitespace and cut all lines starting from the second one. I'd suggest another way: while IFS= read -r linenum line. The shell will perform wordsplitting on the input line and place first item ( line numbers ) into linenum variable, but all other things will go into line variable. Aside from other things, case statement can be used as alternative to [[ comparison.
          – Sergiy Kolodyazhnyy
          Dec 4 at 18:44




          @George So you're using -d" " to split on whitespace and cut all lines starting from the second one. I'd suggest another way: while IFS= read -r linenum line. The shell will perform wordsplitting on the input line and place first item ( line numbers ) into linenum variable, but all other things will go into line variable. Aside from other things, case statement can be used as alternative to [[ comparison.
          – Sergiy Kolodyazhnyy
          Dec 4 at 18:44












          Can I implement this script in #!/bin/sh ?
          – ShellyBelly
          Dec 4 at 18:49




          Can I implement this script in #!/bin/sh ?
          – ShellyBelly
          Dec 4 at 18:49












          @AkshayNandi Yes, but you need to change [[ to [ because [[ is specific to bash. See my answer for portable solution
          – Sergiy Kolodyazhnyy
          Dec 4 at 18:52




          @AkshayNandi Yes, but you need to change [[ to [ because [[ is specific to bash. See my answer for portable solution
          – Sergiy Kolodyazhnyy
          Dec 4 at 18:52












          @SergiyKolodyazhnyy I tried that it didn't do so on the word splitting.
          – George Udosen
          Dec 4 at 19:36




          @SergiyKolodyazhnyy I tried that it didn't do so on the word splitting.
          – George Udosen
          Dec 4 at 19:36




          1




          1




          @GeorgeUdosen Ah, yes, I found the issue - it's because of IFS=. It unsets the variable temporarily, which is what is used for word splitting. IFS defaults to whitespace,tab,and newline. And it's a habit, but also for a good reason, to unset it - if there's a leading whitespace ( line starts with space ) it would be gone without IFS=
          – Sergiy Kolodyazhnyy
          Dec 5 at 0:07




          @GeorgeUdosen Ah, yes, I found the issue - it's because of IFS=. It unsets the variable temporarily, which is what is used for word splitting. IFS defaults to whitespace,tab,and newline. And it's a habit, but also for a good reason, to unset it - if there's a leading whitespace ( line starts with space ) it would be gone without IFS=
          – Sergiy Kolodyazhnyy
          Dec 5 at 0:07


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Ask Ubuntu!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1098445%2fhow-do-i-read-line-by-line-in-a-file-using-while-loop-and-in-each-iteration-gr%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Bressuire

          Cabo Verde

          Gyllenstierna