Only one line in script outputWhat is the difference between touch file and > file?run bash script from...

Do I have an "anti-research" personality?

Why do games have consumables?

Why is it that the natural deduction method can't test for invalidity?

Is the 5 MB static resource size limit 5,242,880 bytes or 5,000,000 bytes?

Does Gita support doctrine of eternal cycle of birth and death for evil people?

Why do Computer Science majors learn Calculus?

simple conditions equation

Stop and Take a Breath!

How do I reattach a shelf to the wall when it ripped out of the wall?

How to type a section sign (§) into the Minecraft client

How to stop co-workers from teasing me because I know Russian?

Rivers without rain

Does holding a wand and speaking its command word count as V/S/M spell components?

Combinable filters

Pulling the rope with one hand is as heavy as with two hands?

How to pronounce 'C++' in Spanish

How much cash can I safely carry into the USA and avoid civil forfeiture?

Why isn't the definition of absolute value applied when squaring a radical containing a variable?

How to verbalise code in Mathematica?

What's the polite way to say "I need to urinate"?

How can Republicans who favour free markets, consistently express anger when they don't like the outcome of that choice?

Examples of non trivial equivalence relations , I mean equivalence relations without the expression " same ... as" in their definition?

What happened to Captain America in Endgame?

What do the phrase "Reeyan's seacrest" and the word "fraggle" mean in a sketch?



Only one line in script output


What is the difference between touch file and > file?run bash script from another script and redirect its outputHow to replace a string of text with input from another filePrint only one line at a time from text fileHow to squash all the contents of a multi-line file onto one line?How to run a script automatically in linux?Redirect 2 commands to a file on the same line scriptWhy does `read -r` still only get the first word of each line?How to read line by line multiple filesSelect the remaining text in a line from a log fileCreate bash script that allows you to choose multiple options instead of just one?






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







4















There are multiple lines in my input file but my output file Token.csv only has one output line like this:



4TF16B7GA129E
4TF16B7GA129S
4TF16B7GA129D
4TF16B7GA129X


How to process every line?



My Code:



epoch=$(date -d "`date`" +"%s")
StringCsv="/home/Desktop/TokenGenScript/SerialNos.csv"
StringToken=b5242a2d7973c1aca3723c834ba0d239

while IFS=$'n' read -r line || [ -n "$line" ]
do
j=$line
serial=${j}:${epoch}:${StringToken}
echo "$serial"|sha256sum > Token.csv
done < "$StringCsv"








share









New contributor




Shubham Agrawal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    and your code is not working or what is the problem? Btw, you don't need the doubled date.

    – RoVo
    yesterday


















4















There are multiple lines in my input file but my output file Token.csv only has one output line like this:



4TF16B7GA129E
4TF16B7GA129S
4TF16B7GA129D
4TF16B7GA129X


How to process every line?



My Code:



epoch=$(date -d "`date`" +"%s")
StringCsv="/home/Desktop/TokenGenScript/SerialNos.csv"
StringToken=b5242a2d7973c1aca3723c834ba0d239

while IFS=$'n' read -r line || [ -n "$line" ]
do
j=$line
serial=${j}:${epoch}:${StringToken}
echo "$serial"|sha256sum > Token.csv
done < "$StringCsv"








share









New contributor




Shubham Agrawal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    and your code is not working or what is the problem? Btw, you don't need the doubled date.

    – RoVo
    yesterday














4












4








4








There are multiple lines in my input file but my output file Token.csv only has one output line like this:



4TF16B7GA129E
4TF16B7GA129S
4TF16B7GA129D
4TF16B7GA129X


How to process every line?



My Code:



epoch=$(date -d "`date`" +"%s")
StringCsv="/home/Desktop/TokenGenScript/SerialNos.csv"
StringToken=b5242a2d7973c1aca3723c834ba0d239

while IFS=$'n' read -r line || [ -n "$line" ]
do
j=$line
serial=${j}:${epoch}:${StringToken}
echo "$serial"|sha256sum > Token.csv
done < "$StringCsv"








share









New contributor




Shubham Agrawal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












There are multiple lines in my input file but my output file Token.csv only has one output line like this:



4TF16B7GA129E
4TF16B7GA129S
4TF16B7GA129D
4TF16B7GA129X


How to process every line?



My Code:



epoch=$(date -d "`date`" +"%s")
StringCsv="/home/Desktop/TokenGenScript/SerialNos.csv"
StringToken=b5242a2d7973c1aca3723c834ba0d239

while IFS=$'n' read -r line || [ -n "$line" ]
do
j=$line
serial=${j}:${epoch}:${StringToken}
echo "$serial"|sha256sum > Token.csv
done < "$StringCsv"






command-line bash scripts





share









New contributor




Shubham Agrawal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share









New contributor




Shubham Agrawal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share



share








edited 14 hours ago









Monty Harder

29416




29416






New contributor




Shubham Agrawal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









Shubham AgrawalShubham Agrawal

241




241




New contributor




Shubham Agrawal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Shubham Agrawal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Shubham Agrawal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 1





    and your code is not working or what is the problem? Btw, you don't need the doubled date.

    – RoVo
    yesterday














  • 1





    and your code is not working or what is the problem? Btw, you don't need the doubled date.

    – RoVo
    yesterday








1




1





and your code is not working or what is the problem? Btw, you don't need the doubled date.

– RoVo
yesterday





and your code is not working or what is the problem? Btw, you don't need the doubled date.

– RoVo
yesterday










4 Answers
4






active

oldest

votes


















5














Put the output redirection on the entire loop, not just the sha256sum command. Every time you redirect, you're recreating the output file from scratch. This will just create it once, and write to it repeatedly within the loop.



while IFS=$'n' read -r line || [ -n "$line" ]
do
j=$line
serial=${j}:${epoch}:${StringToken}
echo "$serial"|sha256sum
done < "$StringCsv" > Token.csv





share|improve this answer































    5














    You are writing to a file in a loop with this command:



    echo "$serial"|sha256sum > Token.csv


    However each time you loop you are erasing the file and writing a new entry. What you want to do is append (add to) the file each time you loop with this command:



    echo "$serial"|sha256sum >> Token.csv


    A single > tells bash to erase the file Token.csv and write the contents. A double >> tells bash to add to the end of the file.





    The bash script would now look like this:



    #!/bin/bash
    epoch=$(date -d "`date`" +"%s")
    StringCsv="/home/Desktop/TokenGenScript/SerialNos.csv"
    StringToken=b5242a2d7973c1aca3723c834ba0d239

    > Token.csv # Empty file from last run

    while IFS=$'n' read -r line || [ -n "$line" ]
    do
    j=$line
    serial=${j}:${epoch}:${StringToken}
    echo "$serial"|sha256sum >> Token.csv # Append new record to end
    done < "$StringCsv"




    There are two ways to create a new empty file > Token.csv as used above and touch Token.csv. However only > Token.csv will empty an existing file. See:




    • What is the difference between touch file and > file?






    share|improve this answer


























    • There should probably be an explicit removal/truncation of Token.csv prior to the loop, to assure this run doesn't append to any existing file contents.

      – Monty Harder
      yesterday











    • As you explained in your answer to the question you linked to,  touch does not empty a file.

      – Scott
      7 hours ago













    • @Scott Yes that was misleading. I've reworded it. Thanks for pointing that out.

      – WinEunuuchs2Unix
      7 hours ago











    • @MontyHarder I've added a full script now.

      – WinEunuuchs2Unix
      7 hours ago











    • @Scott Double thanks. OP never had a shebang in the first place which I was planning to mention in the answer as well. The whole second edit was rather rushed as I had a priority project under way.

      – WinEunuuchs2Unix
      6 hours ago



















    0














    Use the command below for reading n lines from file:



    head -n 1 filename


    to write it to variable use this:



    var=$(head -n 1 filename);


    Or you can read nth line from file:



    sed -n '2p' filename


    The comand above will return second line of file. For your example you can use this:
    sed -n $i'p' filename
    where i is index.



    BUT, for your code you need an index that will increase every iteration.






    share|improve this answer










    New contributor




    Vlad Gavriuk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.




























      0














      Taking Why is using a shell loop to process text considered bad practice? way too seriously, and using GNU Awk's getline from a Coprocess:



      gawk -v stringToken=b5242a2d7973c1aca3723c834ba0d239 '
      BEGIN{cmd="sha256sum"; s = systime()}
      {
      print $0 s stringToken |& cmd; close(cmd,"to");
      cmd |& getline; close(cmd,"from")
      } 1
      ' SerialNos.csv > Token.csv





      share|improve this answer
























        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',
        autoActivateHeartbeat: false,
        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
        });


        }
        });






        Shubham Agrawal is a new contributor. Be nice, and check out our Code of Conduct.










        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1138318%2fonly-one-line-in-script-output%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        5














        Put the output redirection on the entire loop, not just the sha256sum command. Every time you redirect, you're recreating the output file from scratch. This will just create it once, and write to it repeatedly within the loop.



        while IFS=$'n' read -r line || [ -n "$line" ]
        do
        j=$line
        serial=${j}:${epoch}:${StringToken}
        echo "$serial"|sha256sum
        done < "$StringCsv" > Token.csv





        share|improve this answer




























          5














          Put the output redirection on the entire loop, not just the sha256sum command. Every time you redirect, you're recreating the output file from scratch. This will just create it once, and write to it repeatedly within the loop.



          while IFS=$'n' read -r line || [ -n "$line" ]
          do
          j=$line
          serial=${j}:${epoch}:${StringToken}
          echo "$serial"|sha256sum
          done < "$StringCsv" > Token.csv





          share|improve this answer


























            5












            5








            5







            Put the output redirection on the entire loop, not just the sha256sum command. Every time you redirect, you're recreating the output file from scratch. This will just create it once, and write to it repeatedly within the loop.



            while IFS=$'n' read -r line || [ -n "$line" ]
            do
            j=$line
            serial=${j}:${epoch}:${StringToken}
            echo "$serial"|sha256sum
            done < "$StringCsv" > Token.csv





            share|improve this answer













            Put the output redirection on the entire loop, not just the sha256sum command. Every time you redirect, you're recreating the output file from scratch. This will just create it once, and write to it repeatedly within the loop.



            while IFS=$'n' read -r line || [ -n "$line" ]
            do
            j=$line
            serial=${j}:${epoch}:${StringToken}
            echo "$serial"|sha256sum
            done < "$StringCsv" > Token.csv






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered yesterday









            BarmarBarmar

            1856




            1856

























                5














                You are writing to a file in a loop with this command:



                echo "$serial"|sha256sum > Token.csv


                However each time you loop you are erasing the file and writing a new entry. What you want to do is append (add to) the file each time you loop with this command:



                echo "$serial"|sha256sum >> Token.csv


                A single > tells bash to erase the file Token.csv and write the contents. A double >> tells bash to add to the end of the file.





                The bash script would now look like this:



                #!/bin/bash
                epoch=$(date -d "`date`" +"%s")
                StringCsv="/home/Desktop/TokenGenScript/SerialNos.csv"
                StringToken=b5242a2d7973c1aca3723c834ba0d239

                > Token.csv # Empty file from last run

                while IFS=$'n' read -r line || [ -n "$line" ]
                do
                j=$line
                serial=${j}:${epoch}:${StringToken}
                echo "$serial"|sha256sum >> Token.csv # Append new record to end
                done < "$StringCsv"




                There are two ways to create a new empty file > Token.csv as used above and touch Token.csv. However only > Token.csv will empty an existing file. See:




                • What is the difference between touch file and > file?






                share|improve this answer


























                • There should probably be an explicit removal/truncation of Token.csv prior to the loop, to assure this run doesn't append to any existing file contents.

                  – Monty Harder
                  yesterday











                • As you explained in your answer to the question you linked to,  touch does not empty a file.

                  – Scott
                  7 hours ago













                • @Scott Yes that was misleading. I've reworded it. Thanks for pointing that out.

                  – WinEunuuchs2Unix
                  7 hours ago











                • @MontyHarder I've added a full script now.

                  – WinEunuuchs2Unix
                  7 hours ago











                • @Scott Double thanks. OP never had a shebang in the first place which I was planning to mention in the answer as well. The whole second edit was rather rushed as I had a priority project under way.

                  – WinEunuuchs2Unix
                  6 hours ago
















                5














                You are writing to a file in a loop with this command:



                echo "$serial"|sha256sum > Token.csv


                However each time you loop you are erasing the file and writing a new entry. What you want to do is append (add to) the file each time you loop with this command:



                echo "$serial"|sha256sum >> Token.csv


                A single > tells bash to erase the file Token.csv and write the contents. A double >> tells bash to add to the end of the file.





                The bash script would now look like this:



                #!/bin/bash
                epoch=$(date -d "`date`" +"%s")
                StringCsv="/home/Desktop/TokenGenScript/SerialNos.csv"
                StringToken=b5242a2d7973c1aca3723c834ba0d239

                > Token.csv # Empty file from last run

                while IFS=$'n' read -r line || [ -n "$line" ]
                do
                j=$line
                serial=${j}:${epoch}:${StringToken}
                echo "$serial"|sha256sum >> Token.csv # Append new record to end
                done < "$StringCsv"




                There are two ways to create a new empty file > Token.csv as used above and touch Token.csv. However only > Token.csv will empty an existing file. See:




                • What is the difference between touch file and > file?






                share|improve this answer


























                • There should probably be an explicit removal/truncation of Token.csv prior to the loop, to assure this run doesn't append to any existing file contents.

                  – Monty Harder
                  yesterday











                • As you explained in your answer to the question you linked to,  touch does not empty a file.

                  – Scott
                  7 hours ago













                • @Scott Yes that was misleading. I've reworded it. Thanks for pointing that out.

                  – WinEunuuchs2Unix
                  7 hours ago











                • @MontyHarder I've added a full script now.

                  – WinEunuuchs2Unix
                  7 hours ago











                • @Scott Double thanks. OP never had a shebang in the first place which I was planning to mention in the answer as well. The whole second edit was rather rushed as I had a priority project under way.

                  – WinEunuuchs2Unix
                  6 hours ago














                5












                5








                5







                You are writing to a file in a loop with this command:



                echo "$serial"|sha256sum > Token.csv


                However each time you loop you are erasing the file and writing a new entry. What you want to do is append (add to) the file each time you loop with this command:



                echo "$serial"|sha256sum >> Token.csv


                A single > tells bash to erase the file Token.csv and write the contents. A double >> tells bash to add to the end of the file.





                The bash script would now look like this:



                #!/bin/bash
                epoch=$(date -d "`date`" +"%s")
                StringCsv="/home/Desktop/TokenGenScript/SerialNos.csv"
                StringToken=b5242a2d7973c1aca3723c834ba0d239

                > Token.csv # Empty file from last run

                while IFS=$'n' read -r line || [ -n "$line" ]
                do
                j=$line
                serial=${j}:${epoch}:${StringToken}
                echo "$serial"|sha256sum >> Token.csv # Append new record to end
                done < "$StringCsv"




                There are two ways to create a new empty file > Token.csv as used above and touch Token.csv. However only > Token.csv will empty an existing file. See:




                • What is the difference between touch file and > file?






                share|improve this answer















                You are writing to a file in a loop with this command:



                echo "$serial"|sha256sum > Token.csv


                However each time you loop you are erasing the file and writing a new entry. What you want to do is append (add to) the file each time you loop with this command:



                echo "$serial"|sha256sum >> Token.csv


                A single > tells bash to erase the file Token.csv and write the contents. A double >> tells bash to add to the end of the file.





                The bash script would now look like this:



                #!/bin/bash
                epoch=$(date -d "`date`" +"%s")
                StringCsv="/home/Desktop/TokenGenScript/SerialNos.csv"
                StringToken=b5242a2d7973c1aca3723c834ba0d239

                > Token.csv # Empty file from last run

                while IFS=$'n' read -r line || [ -n "$line" ]
                do
                j=$line
                serial=${j}:${epoch}:${StringToken}
                echo "$serial"|sha256sum >> Token.csv # Append new record to end
                done < "$StringCsv"




                There are two ways to create a new empty file > Token.csv as used above and touch Token.csv. However only > Token.csv will empty an existing file. See:




                • What is the difference between touch file and > file?







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 7 hours ago

























                answered yesterday









                WinEunuuchs2UnixWinEunuuchs2Unix

                48.7k1198187




                48.7k1198187













                • There should probably be an explicit removal/truncation of Token.csv prior to the loop, to assure this run doesn't append to any existing file contents.

                  – Monty Harder
                  yesterday











                • As you explained in your answer to the question you linked to,  touch does not empty a file.

                  – Scott
                  7 hours ago













                • @Scott Yes that was misleading. I've reworded it. Thanks for pointing that out.

                  – WinEunuuchs2Unix
                  7 hours ago











                • @MontyHarder I've added a full script now.

                  – WinEunuuchs2Unix
                  7 hours ago











                • @Scott Double thanks. OP never had a shebang in the first place which I was planning to mention in the answer as well. The whole second edit was rather rushed as I had a priority project under way.

                  – WinEunuuchs2Unix
                  6 hours ago



















                • There should probably be an explicit removal/truncation of Token.csv prior to the loop, to assure this run doesn't append to any existing file contents.

                  – Monty Harder
                  yesterday











                • As you explained in your answer to the question you linked to,  touch does not empty a file.

                  – Scott
                  7 hours ago













                • @Scott Yes that was misleading. I've reworded it. Thanks for pointing that out.

                  – WinEunuuchs2Unix
                  7 hours ago











                • @MontyHarder I've added a full script now.

                  – WinEunuuchs2Unix
                  7 hours ago











                • @Scott Double thanks. OP never had a shebang in the first place which I was planning to mention in the answer as well. The whole second edit was rather rushed as I had a priority project under way.

                  – WinEunuuchs2Unix
                  6 hours ago

















                There should probably be an explicit removal/truncation of Token.csv prior to the loop, to assure this run doesn't append to any existing file contents.

                – Monty Harder
                yesterday





                There should probably be an explicit removal/truncation of Token.csv prior to the loop, to assure this run doesn't append to any existing file contents.

                – Monty Harder
                yesterday













                As you explained in your answer to the question you linked to,  touch does not empty a file.

                – Scott
                7 hours ago







                As you explained in your answer to the question you linked to,  touch does not empty a file.

                – Scott
                7 hours ago















                @Scott Yes that was misleading. I've reworded it. Thanks for pointing that out.

                – WinEunuuchs2Unix
                7 hours ago





                @Scott Yes that was misleading. I've reworded it. Thanks for pointing that out.

                – WinEunuuchs2Unix
                7 hours ago













                @MontyHarder I've added a full script now.

                – WinEunuuchs2Unix
                7 hours ago





                @MontyHarder I've added a full script now.

                – WinEunuuchs2Unix
                7 hours ago













                @Scott Double thanks. OP never had a shebang in the first place which I was planning to mention in the answer as well. The whole second edit was rather rushed as I had a priority project under way.

                – WinEunuuchs2Unix
                6 hours ago





                @Scott Double thanks. OP never had a shebang in the first place which I was planning to mention in the answer as well. The whole second edit was rather rushed as I had a priority project under way.

                – WinEunuuchs2Unix
                6 hours ago











                0














                Use the command below for reading n lines from file:



                head -n 1 filename


                to write it to variable use this:



                var=$(head -n 1 filename);


                Or you can read nth line from file:



                sed -n '2p' filename


                The comand above will return second line of file. For your example you can use this:
                sed -n $i'p' filename
                where i is index.



                BUT, for your code you need an index that will increase every iteration.






                share|improve this answer










                New contributor




                Vlad Gavriuk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.

























                  0














                  Use the command below for reading n lines from file:



                  head -n 1 filename


                  to write it to variable use this:



                  var=$(head -n 1 filename);


                  Or you can read nth line from file:



                  sed -n '2p' filename


                  The comand above will return second line of file. For your example you can use this:
                  sed -n $i'p' filename
                  where i is index.



                  BUT, for your code you need an index that will increase every iteration.






                  share|improve this answer










                  New contributor




                  Vlad Gavriuk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.























                    0












                    0








                    0







                    Use the command below for reading n lines from file:



                    head -n 1 filename


                    to write it to variable use this:



                    var=$(head -n 1 filename);


                    Or you can read nth line from file:



                    sed -n '2p' filename


                    The comand above will return second line of file. For your example you can use this:
                    sed -n $i'p' filename
                    where i is index.



                    BUT, for your code you need an index that will increase every iteration.






                    share|improve this answer










                    New contributor




                    Vlad Gavriuk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.










                    Use the command below for reading n lines from file:



                    head -n 1 filename


                    to write it to variable use this:



                    var=$(head -n 1 filename);


                    Or you can read nth line from file:



                    sed -n '2p' filename


                    The comand above will return second line of file. For your example you can use this:
                    sed -n $i'p' filename
                    where i is index.



                    BUT, for your code you need an index that will increase every iteration.







                    share|improve this answer










                    New contributor




                    Vlad Gavriuk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.









                    share|improve this answer



                    share|improve this answer








                    edited yesterday





















                    New contributor




                    Vlad Gavriuk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.









                    answered yesterday









                    Vlad GavriukVlad Gavriuk

                    1113




                    1113




                    New contributor




                    Vlad Gavriuk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.





                    New contributor





                    Vlad Gavriuk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.






                    Vlad Gavriuk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.























                        0














                        Taking Why is using a shell loop to process text considered bad practice? way too seriously, and using GNU Awk's getline from a Coprocess:



                        gawk -v stringToken=b5242a2d7973c1aca3723c834ba0d239 '
                        BEGIN{cmd="sha256sum"; s = systime()}
                        {
                        print $0 s stringToken |& cmd; close(cmd,"to");
                        cmd |& getline; close(cmd,"from")
                        } 1
                        ' SerialNos.csv > Token.csv





                        share|improve this answer




























                          0














                          Taking Why is using a shell loop to process text considered bad practice? way too seriously, and using GNU Awk's getline from a Coprocess:



                          gawk -v stringToken=b5242a2d7973c1aca3723c834ba0d239 '
                          BEGIN{cmd="sha256sum"; s = systime()}
                          {
                          print $0 s stringToken |& cmd; close(cmd,"to");
                          cmd |& getline; close(cmd,"from")
                          } 1
                          ' SerialNos.csv > Token.csv





                          share|improve this answer


























                            0












                            0








                            0







                            Taking Why is using a shell loop to process text considered bad practice? way too seriously, and using GNU Awk's getline from a Coprocess:



                            gawk -v stringToken=b5242a2d7973c1aca3723c834ba0d239 '
                            BEGIN{cmd="sha256sum"; s = systime()}
                            {
                            print $0 s stringToken |& cmd; close(cmd,"to");
                            cmd |& getline; close(cmd,"from")
                            } 1
                            ' SerialNos.csv > Token.csv





                            share|improve this answer













                            Taking Why is using a shell loop to process text considered bad practice? way too seriously, and using GNU Awk's getline from a Coprocess:



                            gawk -v stringToken=b5242a2d7973c1aca3723c834ba0d239 '
                            BEGIN{cmd="sha256sum"; s = systime()}
                            {
                            print $0 s stringToken |& cmd; close(cmd,"to");
                            cmd |& getline; close(cmd,"from")
                            } 1
                            ' SerialNos.csv > Token.csv






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered yesterday









                            steeldriversteeldriver

                            71.4k11115187




                            71.4k11115187






















                                Shubham Agrawal is a new contributor. Be nice, and check out our Code of Conduct.










                                draft saved

                                draft discarded


















                                Shubham Agrawal is a new contributor. Be nice, and check out our Code of Conduct.













                                Shubham Agrawal is a new contributor. Be nice, and check out our Code of Conduct.












                                Shubham Agrawal is a new contributor. Be nice, and check out our Code of Conduct.
















                                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.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1138318%2fonly-one-line-in-script-output%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

                                Why do type traits not work with types in namespace scope?What are POD types in C++?Why can templates only be...

                                Will tsunami waves travel forever if there was no land?Why do tsunami waves begin with the water flowing away...

                                Should I use Docker or LXD?How to cache (more) data on SSD/RAM to avoid spin up?Unable to get Windows File...