new line not append instead append on the end of the line2019 Community Moderator ElectionHow to add a newline to the end of a file?awk not doing a new lineTransferring a variable from one file to anotherVar1 is set to contents of command executed, how to set Var2 to be the command from Var1How to pass multiple arguments through ssh and use those arguments in the ssh script?In bash, how to delay interpolation of a variable that has a dynamic variable within its stringHow to iterate a command with two different variables?Add (prepend) line to file, if parameter is not already existingappend text with echo without new lineBash - How to access a variable with a number suffix using a FOR loopShell script to create one file and append the results

How to preserve electronics (computers, iPads and phones) for hundreds of years

How do I fix the group tension caused by my character stealing and possibly killing without provocation?

El Dorado Word Puzzle II: Videogame Edition

Does Doodling or Improvising on the Piano Have Any Benefits?

What's the name of the logical fallacy where a debater extends a statement far beyond the original statement to make it true?

Sigmoid with a slope but no asymptotes?

How do you justify more code being written by following clean code practices?

How many people need to be born every 8 years to sustain population?

Deciphering cause of death?

Make a Bowl of Alphabet Soup

Isometric embedding of a genus g surface

The Digit Triangles

How do I Interface a PS/2 Keyboard without Modern Techniques?

Can I say "fingers" when referring to toes?

Would this string work as string?

What is the smallest number n> 5 so that 5 ^ n ends with "3125"?

What happens if I try to grapple an illusory duplicate from the Mirror Image spell?

Does the Crossbow Expert feat's extra crossbow attack work with the reaction attack from a Hunter ranger's Giant Killer feature?

Why does the Persian emissary display a string of crowned skulls?

Air travel with refrigerated insulin

Should I assume I have passed probation?

Should I warn new/prospective PhD Student that supervisor is terrible?

Why didn’t Eve recognize the little cockroach as a living organism?

Ways of geometrical multiplication



new line not append instead append on the end of the line



2019 Community Moderator ElectionHow to add a newline to the end of a file?awk not doing a new lineTransferring a variable from one file to anotherVar1 is set to contents of command executed, how to set Var2 to be the command from Var1How to pass multiple arguments through ssh and use those arguments in the ssh script?In bash, how to delay interpolation of a variable that has a dynamic variable within its stringHow to iterate a command with two different variables?Add (prepend) line to file, if parameter is not already existingappend text with echo without new lineBash - How to access a variable with a number suffix using a FOR loopShell script to create one file and append the results










0















we gave the following config file ( config.txt )



more config.txt
export var1=345476746


but when I am appending new parameter as



echo "export var2=5645" >> config.txt


we get



more config.txt
export var1=345476746export var2=5645


how to avoid this?



so we get



more config.txt
export var1=345476746
export var2=5645









share|improve this question

















  • 2





    config.txt has no newline at the end of the file. Fix that or simply add one before adding var2.

    – RoVo
    19 hours ago












  • still not understand how to add "n" on each line , seems that last line isn't with "n"

    – yael
    19 hours ago











  • If your text file is generated by common text editors in Unix, there should be a newline in the end of the file because that is required by the POSIX standard. In vim, files without n in the last line is indicated in the status line by [noeol].

    – Weijun Zhou
    19 hours ago











  • possible duplicate of How to add a newline to the end of a file?

    – Stéphane Chazelas
    14 hours ago











  • See also What's the point in adding a new line to the end of a file?

    – Stéphane Chazelas
    14 hours ago















0















we gave the following config file ( config.txt )



more config.txt
export var1=345476746


but when I am appending new parameter as



echo "export var2=5645" >> config.txt


we get



more config.txt
export var1=345476746export var2=5645


how to avoid this?



so we get



more config.txt
export var1=345476746
export var2=5645









share|improve this question

















  • 2





    config.txt has no newline at the end of the file. Fix that or simply add one before adding var2.

    – RoVo
    19 hours ago












  • still not understand how to add "n" on each line , seems that last line isn't with "n"

    – yael
    19 hours ago











  • If your text file is generated by common text editors in Unix, there should be a newline in the end of the file because that is required by the POSIX standard. In vim, files without n in the last line is indicated in the status line by [noeol].

    – Weijun Zhou
    19 hours ago











  • possible duplicate of How to add a newline to the end of a file?

    – Stéphane Chazelas
    14 hours ago











  • See also What's the point in adding a new line to the end of a file?

    – Stéphane Chazelas
    14 hours ago













0












0








0








we gave the following config file ( config.txt )



more config.txt
export var1=345476746


but when I am appending new parameter as



echo "export var2=5645" >> config.txt


we get



more config.txt
export var1=345476746export var2=5645


how to avoid this?



so we get



more config.txt
export var1=345476746
export var2=5645









share|improve this question














we gave the following config file ( config.txt )



more config.txt
export var1=345476746


but when I am appending new parameter as



echo "export var2=5645" >> config.txt


we get



more config.txt
export var1=345476746export var2=5645


how to avoid this?



so we get



more config.txt
export var1=345476746
export var2=5645






linux bash shell-script shell






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 19 hours ago









yaelyael

2,73422575




2,73422575







  • 2





    config.txt has no newline at the end of the file. Fix that or simply add one before adding var2.

    – RoVo
    19 hours ago












  • still not understand how to add "n" on each line , seems that last line isn't with "n"

    – yael
    19 hours ago











  • If your text file is generated by common text editors in Unix, there should be a newline in the end of the file because that is required by the POSIX standard. In vim, files without n in the last line is indicated in the status line by [noeol].

    – Weijun Zhou
    19 hours ago











  • possible duplicate of How to add a newline to the end of a file?

    – Stéphane Chazelas
    14 hours ago











  • See also What's the point in adding a new line to the end of a file?

    – Stéphane Chazelas
    14 hours ago












  • 2





    config.txt has no newline at the end of the file. Fix that or simply add one before adding var2.

    – RoVo
    19 hours ago












  • still not understand how to add "n" on each line , seems that last line isn't with "n"

    – yael
    19 hours ago











  • If your text file is generated by common text editors in Unix, there should be a newline in the end of the file because that is required by the POSIX standard. In vim, files without n in the last line is indicated in the status line by [noeol].

    – Weijun Zhou
    19 hours ago











  • possible duplicate of How to add a newline to the end of a file?

    – Stéphane Chazelas
    14 hours ago











  • See also What's the point in adding a new line to the end of a file?

    – Stéphane Chazelas
    14 hours ago







2




2





config.txt has no newline at the end of the file. Fix that or simply add one before adding var2.

– RoVo
19 hours ago






config.txt has no newline at the end of the file. Fix that or simply add one before adding var2.

– RoVo
19 hours ago














still not understand how to add "n" on each line , seems that last line isn't with "n"

– yael
19 hours ago





still not understand how to add "n" on each line , seems that last line isn't with "n"

– yael
19 hours ago













If your text file is generated by common text editors in Unix, there should be a newline in the end of the file because that is required by the POSIX standard. In vim, files without n in the last line is indicated in the status line by [noeol].

– Weijun Zhou
19 hours ago





If your text file is generated by common text editors in Unix, there should be a newline in the end of the file because that is required by the POSIX standard. In vim, files without n in the last line is indicated in the status line by [noeol].

– Weijun Zhou
19 hours ago













possible duplicate of How to add a newline to the end of a file?

– Stéphane Chazelas
14 hours ago





possible duplicate of How to add a newline to the end of a file?

– Stéphane Chazelas
14 hours ago













See also What's the point in adding a new line to the end of a file?

– Stéphane Chazelas
14 hours ago





See also What's the point in adding a new line to the end of a file?

– Stéphane Chazelas
14 hours ago










2 Answers
2






active

oldest

votes


















0














Probably you should have inserted the text export var1=345476746 with -n option initially.




-n do not output the trailing newline




Example :



echo -n "export var1=345476746" > config.txt
echo "export var2=5645" >> config.txt


Results :



# more config.txt 
export var1=345476746export var2=5645





share|improve this answer






























    0














    Your config.txt has no newline at the end of the file.



    The posix standard says there should be:




    3.206 Line

    A sequence of zero or more non- characters plus a terminating <newline> character.




    You can add a new line, e.g.:



    sed -i -e '$a' config.txt


    This will add a new line only when there is not already one at the end.



    In your case a simple echo >> config.txt would do the job.






    share|improve this answer

























    • A simple echo >> config.txt should do the work if it is just missing the final n.

      – Weijun Zhou
      19 hours ago






    • 1





      In this case yes, but it will append a newline if it's missing or not.

      – RoVo
      18 hours ago











    • It's quite inefficient though and is not without side effect (like breaking symlinks, hardlinks, possibly changing file owership) as it makes full copy of the file.

      – Stéphane Chazelas
      14 hours ago











    • @Stéphane, If you have a better idea, you could post it on unix.stackexchange.com/questions/31947/…, or comment on the highest voted answer.

      – RoVo
      13 hours ago










    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
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f507359%2fnew-line-not-append-instead-append-on-the-end-of-the-line%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









    0














    Probably you should have inserted the text export var1=345476746 with -n option initially.




    -n do not output the trailing newline




    Example :



    echo -n "export var1=345476746" > config.txt
    echo "export var2=5645" >> config.txt


    Results :



    # more config.txt 
    export var1=345476746export var2=5645





    share|improve this answer



























      0














      Probably you should have inserted the text export var1=345476746 with -n option initially.




      -n do not output the trailing newline




      Example :



      echo -n "export var1=345476746" > config.txt
      echo "export var2=5645" >> config.txt


      Results :



      # more config.txt 
      export var1=345476746export var2=5645





      share|improve this answer

























        0












        0








        0







        Probably you should have inserted the text export var1=345476746 with -n option initially.




        -n do not output the trailing newline




        Example :



        echo -n "export var1=345476746" > config.txt
        echo "export var2=5645" >> config.txt


        Results :



        # more config.txt 
        export var1=345476746export var2=5645





        share|improve this answer













        Probably you should have inserted the text export var1=345476746 with -n option initially.




        -n do not output the trailing newline




        Example :



        echo -n "export var1=345476746" > config.txt
        echo "export var2=5645" >> config.txt


        Results :



        # more config.txt 
        export var1=345476746export var2=5645






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 14 hours ago









        msp9011msp9011

        4,44344167




        4,44344167























            0














            Your config.txt has no newline at the end of the file.



            The posix standard says there should be:




            3.206 Line

            A sequence of zero or more non- characters plus a terminating <newline> character.




            You can add a new line, e.g.:



            sed -i -e '$a' config.txt


            This will add a new line only when there is not already one at the end.



            In your case a simple echo >> config.txt would do the job.






            share|improve this answer

























            • A simple echo >> config.txt should do the work if it is just missing the final n.

              – Weijun Zhou
              19 hours ago






            • 1





              In this case yes, but it will append a newline if it's missing or not.

              – RoVo
              18 hours ago











            • It's quite inefficient though and is not without side effect (like breaking symlinks, hardlinks, possibly changing file owership) as it makes full copy of the file.

              – Stéphane Chazelas
              14 hours ago











            • @Stéphane, If you have a better idea, you could post it on unix.stackexchange.com/questions/31947/…, or comment on the highest voted answer.

              – RoVo
              13 hours ago















            0














            Your config.txt has no newline at the end of the file.



            The posix standard says there should be:




            3.206 Line

            A sequence of zero or more non- characters plus a terminating <newline> character.




            You can add a new line, e.g.:



            sed -i -e '$a' config.txt


            This will add a new line only when there is not already one at the end.



            In your case a simple echo >> config.txt would do the job.






            share|improve this answer

























            • A simple echo >> config.txt should do the work if it is just missing the final n.

              – Weijun Zhou
              19 hours ago






            • 1





              In this case yes, but it will append a newline if it's missing or not.

              – RoVo
              18 hours ago











            • It's quite inefficient though and is not without side effect (like breaking symlinks, hardlinks, possibly changing file owership) as it makes full copy of the file.

              – Stéphane Chazelas
              14 hours ago











            • @Stéphane, If you have a better idea, you could post it on unix.stackexchange.com/questions/31947/…, or comment on the highest voted answer.

              – RoVo
              13 hours ago













            0












            0








            0







            Your config.txt has no newline at the end of the file.



            The posix standard says there should be:




            3.206 Line

            A sequence of zero or more non- characters plus a terminating <newline> character.




            You can add a new line, e.g.:



            sed -i -e '$a' config.txt


            This will add a new line only when there is not already one at the end.



            In your case a simple echo >> config.txt would do the job.






            share|improve this answer















            Your config.txt has no newline at the end of the file.



            The posix standard says there should be:




            3.206 Line

            A sequence of zero or more non- characters plus a terminating <newline> character.




            You can add a new line, e.g.:



            sed -i -e '$a' config.txt


            This will add a new line only when there is not already one at the end.



            In your case a simple echo >> config.txt would do the job.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 13 hours ago

























            answered 19 hours ago









            RoVoRoVo

            3,332317




            3,332317












            • A simple echo >> config.txt should do the work if it is just missing the final n.

              – Weijun Zhou
              19 hours ago






            • 1





              In this case yes, but it will append a newline if it's missing or not.

              – RoVo
              18 hours ago











            • It's quite inefficient though and is not without side effect (like breaking symlinks, hardlinks, possibly changing file owership) as it makes full copy of the file.

              – Stéphane Chazelas
              14 hours ago











            • @Stéphane, If you have a better idea, you could post it on unix.stackexchange.com/questions/31947/…, or comment on the highest voted answer.

              – RoVo
              13 hours ago

















            • A simple echo >> config.txt should do the work if it is just missing the final n.

              – Weijun Zhou
              19 hours ago






            • 1





              In this case yes, but it will append a newline if it's missing or not.

              – RoVo
              18 hours ago











            • It's quite inefficient though and is not without side effect (like breaking symlinks, hardlinks, possibly changing file owership) as it makes full copy of the file.

              – Stéphane Chazelas
              14 hours ago











            • @Stéphane, If you have a better idea, you could post it on unix.stackexchange.com/questions/31947/…, or comment on the highest voted answer.

              – RoVo
              13 hours ago
















            A simple echo >> config.txt should do the work if it is just missing the final n.

            – Weijun Zhou
            19 hours ago





            A simple echo >> config.txt should do the work if it is just missing the final n.

            – Weijun Zhou
            19 hours ago




            1




            1





            In this case yes, but it will append a newline if it's missing or not.

            – RoVo
            18 hours ago





            In this case yes, but it will append a newline if it's missing or not.

            – RoVo
            18 hours ago













            It's quite inefficient though and is not without side effect (like breaking symlinks, hardlinks, possibly changing file owership) as it makes full copy of the file.

            – Stéphane Chazelas
            14 hours ago





            It's quite inefficient though and is not without side effect (like breaking symlinks, hardlinks, possibly changing file owership) as it makes full copy of the file.

            – Stéphane Chazelas
            14 hours ago













            @Stéphane, If you have a better idea, you could post it on unix.stackexchange.com/questions/31947/…, or comment on the highest voted answer.

            – RoVo
            13 hours ago





            @Stéphane, If you have a better idea, you could post it on unix.stackexchange.com/questions/31947/…, or comment on the highest voted answer.

            – RoVo
            13 hours ago

















            draft saved

            draft discarded
















































            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%2f507359%2fnew-line-not-append-instead-append-on-the-end-of-the-line%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

            getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

            Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

            Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.