Write file with 2 columns using shell scriptShell scripting to divide numbers inside a fileMerge two-columns...

Can an old DSLR be upgraded to match modern smartphone image quality

How did early x86 BIOS programmers manage to program full blown TUIs given very few bytes of ROM/EPROM?

How to prevent bad sectors?

Why is there a need to modify system call tables in linux?

What are the slash markings on Gatwick's 08R/26L?

Is there an evolutionary advantage to having two heads?

Humans meet a distant alien species. How do they standardize? - Units of Measure

What does "Marchentalender" on the front of a postcard mean?

Using PCA vs Linear Regression

What does "tea juice" mean in this context?

How do I subvert the tropes of a train heist?

Smart people send dumb people to a new planet on a space craft that crashes into a body of water

Different PCB color ( is it different material? )

What are the benefits of cryosleep?

Could IPv6 make NAT / port numbers redundant?

How can I offer a test ride while selling a bike?

Intuition behind eigenvalues of an adjacency matrix

Is a hash a zero-knowledge proof?

Where did the “vikings wear helmets with horn” stereotype come from and why?

Understanding STM32 datasheet regarding decoupling capacitors

How to detach yourself from a character you're going to kill?

Do Multiclassed spellcasters add their ability modifier or proficiency bonus twice when determining spell save DC?

Asking bank to reduce APR instead of increasing credit limit

chmod would set file permission to 000 no matter what permission i try to set



Write file with 2 columns using shell script


Shell scripting to divide numbers inside a fileMerge two-columns files into one fileHow to print the values of variables with incremented numbers using a loop in shell script?Printing all lines of a file with multiple columns in a shell scriptCompare two a columns in two csv files and print to third fileComparing two files and writing mismatched rows along with mismatched columns. Pointing out the mismatched columns is my main problem statementcommand to search two strings in csv file and print output only if both strings are in same rowusing echo command with $ in shell scriptmerge rows of one file based on key columnsExtract values from file using shell script






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







-1















How can I print variables to an output file in two or more columns (using echo for example). I have the following:



grep -oP 'values*=s*K.*' file >x_vs_y  # x values

for X in $(seq 0 50 400)
do
echo "$X" >>x_vs_y # y values
done


Output: (x_vs_y)



1.08759432363
1.08477216702
1.08211988431
1.07947977045
1.07685185457
1.07423631941
1.07163282502
1.06904156798
1.06646245052
0
50
100
150
200
250
300
350
400


With this script I get an output file in a single column (18x1), but I want to get a 9x2 array (X vs Y).
Thanks in advance.










share|improve this question









New contributor



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




















  • Your question isn't clear. echo easily prints two columns. Please show us exactly what you have tried and show how the output differs from what you want.

    – John1024
    52 mins ago











  • Thanks, I clarified what I want to obtain.

    – Yro
    24 mins ago











  • That's much better.

    – John1024
    13 mins ago


















-1















How can I print variables to an output file in two or more columns (using echo for example). I have the following:



grep -oP 'values*=s*K.*' file >x_vs_y  # x values

for X in $(seq 0 50 400)
do
echo "$X" >>x_vs_y # y values
done


Output: (x_vs_y)



1.08759432363
1.08477216702
1.08211988431
1.07947977045
1.07685185457
1.07423631941
1.07163282502
1.06904156798
1.06646245052
0
50
100
150
200
250
300
350
400


With this script I get an output file in a single column (18x1), but I want to get a 9x2 array (X vs Y).
Thanks in advance.










share|improve this question









New contributor



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




















  • Your question isn't clear. echo easily prints two columns. Please show us exactly what you have tried and show how the output differs from what you want.

    – John1024
    52 mins ago











  • Thanks, I clarified what I want to obtain.

    – Yro
    24 mins ago











  • That's much better.

    – John1024
    13 mins ago














-1












-1








-1








How can I print variables to an output file in two or more columns (using echo for example). I have the following:



grep -oP 'values*=s*K.*' file >x_vs_y  # x values

for X in $(seq 0 50 400)
do
echo "$X" >>x_vs_y # y values
done


Output: (x_vs_y)



1.08759432363
1.08477216702
1.08211988431
1.07947977045
1.07685185457
1.07423631941
1.07163282502
1.06904156798
1.06646245052
0
50
100
150
200
250
300
350
400


With this script I get an output file in a single column (18x1), but I want to get a 9x2 array (X vs Y).
Thanks in advance.










share|improve this question









New contributor



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











How can I print variables to an output file in two or more columns (using echo for example). I have the following:



grep -oP 'values*=s*K.*' file >x_vs_y  # x values

for X in $(seq 0 50 400)
do
echo "$X" >>x_vs_y # y values
done


Output: (x_vs_y)



1.08759432363
1.08477216702
1.08211988431
1.07947977045
1.07685185457
1.07423631941
1.07163282502
1.06904156798
1.06646245052
0
50
100
150
200
250
300
350
400


With this script I get an output file in a single column (18x1), but I want to get a 9x2 array (X vs Y).
Thanks in advance.







shell-script shell ubuntu






share|improve this question









New contributor



Yro 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 question









New contributor



Yro 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 question




share|improve this question








edited 21 mins ago







Yro













New contributor



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








asked 1 hour ago









YroYro

12




12




New contributor



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




New contributor




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















  • Your question isn't clear. echo easily prints two columns. Please show us exactly what you have tried and show how the output differs from what you want.

    – John1024
    52 mins ago











  • Thanks, I clarified what I want to obtain.

    – Yro
    24 mins ago











  • That's much better.

    – John1024
    13 mins ago



















  • Your question isn't clear. echo easily prints two columns. Please show us exactly what you have tried and show how the output differs from what you want.

    – John1024
    52 mins ago











  • Thanks, I clarified what I want to obtain.

    – Yro
    24 mins ago











  • That's much better.

    – John1024
    13 mins ago

















Your question isn't clear. echo easily prints two columns. Please show us exactly what you have tried and show how the output differs from what you want.

– John1024
52 mins ago





Your question isn't clear. echo easily prints two columns. Please show us exactly what you have tried and show how the output differs from what you want.

– John1024
52 mins ago













Thanks, I clarified what I want to obtain.

– Yro
24 mins ago





Thanks, I clarified what I want to obtain.

– Yro
24 mins ago













That's much better.

– John1024
13 mins ago





That's much better.

– John1024
13 mins ago










1 Answer
1






active

oldest

votes


















0














Consider this input file:



$ cat file
value = 1.08759432363
value = 1.08477216702
value = 1.08211988431
value = 1.07947977045
value = 1.07685185457
value = 1.07423631941
value = 1.07163282502
value = 1.06904156798
value = 1.06646245052


To print two columns:



$ awk '{print x+0, $3; x+=50}' file
0 1.08759432363
50 1.08477216702
100 1.08211988431
150 1.07947977045
200 1.07685185457
250 1.07423631941
300 1.07163282502
350 1.06904156798
400 1.06646245052





share|improve this answer
























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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
    });


    }
    });






    Yro 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%2funix.stackexchange.com%2fquestions%2f521661%2fwrite-file-with-2-columns-using-shell-script%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Consider this input file:



    $ cat file
    value = 1.08759432363
    value = 1.08477216702
    value = 1.08211988431
    value = 1.07947977045
    value = 1.07685185457
    value = 1.07423631941
    value = 1.07163282502
    value = 1.06904156798
    value = 1.06646245052


    To print two columns:



    $ awk '{print x+0, $3; x+=50}' file
    0 1.08759432363
    50 1.08477216702
    100 1.08211988431
    150 1.07947977045
    200 1.07685185457
    250 1.07423631941
    300 1.07163282502
    350 1.06904156798
    400 1.06646245052





    share|improve this answer




























      0














      Consider this input file:



      $ cat file
      value = 1.08759432363
      value = 1.08477216702
      value = 1.08211988431
      value = 1.07947977045
      value = 1.07685185457
      value = 1.07423631941
      value = 1.07163282502
      value = 1.06904156798
      value = 1.06646245052


      To print two columns:



      $ awk '{print x+0, $3; x+=50}' file
      0 1.08759432363
      50 1.08477216702
      100 1.08211988431
      150 1.07947977045
      200 1.07685185457
      250 1.07423631941
      300 1.07163282502
      350 1.06904156798
      400 1.06646245052





      share|improve this answer


























        0












        0








        0







        Consider this input file:



        $ cat file
        value = 1.08759432363
        value = 1.08477216702
        value = 1.08211988431
        value = 1.07947977045
        value = 1.07685185457
        value = 1.07423631941
        value = 1.07163282502
        value = 1.06904156798
        value = 1.06646245052


        To print two columns:



        $ awk '{print x+0, $3; x+=50}' file
        0 1.08759432363
        50 1.08477216702
        100 1.08211988431
        150 1.07947977045
        200 1.07685185457
        250 1.07423631941
        300 1.07163282502
        350 1.06904156798
        400 1.06646245052





        share|improve this answer













        Consider this input file:



        $ cat file
        value = 1.08759432363
        value = 1.08477216702
        value = 1.08211988431
        value = 1.07947977045
        value = 1.07685185457
        value = 1.07423631941
        value = 1.07163282502
        value = 1.06904156798
        value = 1.06646245052


        To print two columns:



        $ awk '{print x+0, $3; x+=50}' file
        0 1.08759432363
        50 1.08477216702
        100 1.08211988431
        150 1.07947977045
        200 1.07685185457
        250 1.07423631941
        300 1.07163282502
        350 1.06904156798
        400 1.06646245052






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 13 mins ago









        John1024John1024

        49.9k5116131




        49.9k5116131






















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










            draft saved

            draft discarded


















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













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












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
















            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • 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%2funix.stackexchange.com%2fquestions%2f521661%2fwrite-file-with-2-columns-using-shell-script%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

            Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

            Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

            Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...