Linux - Bash - variable assignment with command substitution is missing the newlines [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












0
















This question already has an answer here:



  • Why does my shell script choke on whitespace or other special characters?

    4 answers



I am running into a bit of an issue / quirk here:



[root@s06p5bcsmta001 elves]# TEST=$(cat -e sendlog)
[root@s06p5bcsmta001 elves]# echo $TEST | wc -l
1
[root@s06p5bcsmta001 elves]# cat sendlog | wc -l
1050
[root@s06p5bcsmta001 elves]# TEST=$(cat sendlog)
[root@s06p5bcsmta001 elves]# echo $TEST | wc -l
1
[root@s06p5bcsmta001 elves]# echo -e $TEST | wc -l
1


How do I get the contents of the text file (with n) into the variable?










share|improve this question















marked as duplicate by Jeff Schaller, Anthony Geoghegan, George Vasiliou, Archemar, Kusalananda Feb 6 at 15:26


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













  • 5





    try echo "$TEST" | wc -l

    – Bodo
    Feb 6 at 14:33















0
















This question already has an answer here:



  • Why does my shell script choke on whitespace or other special characters?

    4 answers



I am running into a bit of an issue / quirk here:



[root@s06p5bcsmta001 elves]# TEST=$(cat -e sendlog)
[root@s06p5bcsmta001 elves]# echo $TEST | wc -l
1
[root@s06p5bcsmta001 elves]# cat sendlog | wc -l
1050
[root@s06p5bcsmta001 elves]# TEST=$(cat sendlog)
[root@s06p5bcsmta001 elves]# echo $TEST | wc -l
1
[root@s06p5bcsmta001 elves]# echo -e $TEST | wc -l
1


How do I get the contents of the text file (with n) into the variable?










share|improve this question















marked as duplicate by Jeff Schaller, Anthony Geoghegan, George Vasiliou, Archemar, Kusalananda Feb 6 at 15:26


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













  • 5





    try echo "$TEST" | wc -l

    – Bodo
    Feb 6 at 14:33













0












0








0









This question already has an answer here:



  • Why does my shell script choke on whitespace or other special characters?

    4 answers



I am running into a bit of an issue / quirk here:



[root@s06p5bcsmta001 elves]# TEST=$(cat -e sendlog)
[root@s06p5bcsmta001 elves]# echo $TEST | wc -l
1
[root@s06p5bcsmta001 elves]# cat sendlog | wc -l
1050
[root@s06p5bcsmta001 elves]# TEST=$(cat sendlog)
[root@s06p5bcsmta001 elves]# echo $TEST | wc -l
1
[root@s06p5bcsmta001 elves]# echo -e $TEST | wc -l
1


How do I get the contents of the text file (with n) into the variable?










share|improve this question

















This question already has an answer here:



  • Why does my shell script choke on whitespace or other special characters?

    4 answers



I am running into a bit of an issue / quirk here:



[root@s06p5bcsmta001 elves]# TEST=$(cat -e sendlog)
[root@s06p5bcsmta001 elves]# echo $TEST | wc -l
1
[root@s06p5bcsmta001 elves]# cat sendlog | wc -l
1050
[root@s06p5bcsmta001 elves]# TEST=$(cat sendlog)
[root@s06p5bcsmta001 elves]# echo $TEST | wc -l
1
[root@s06p5bcsmta001 elves]# echo -e $TEST | wc -l
1


How do I get the contents of the text file (with n) into the variable?





This question already has an answer here:



  • Why does my shell script choke on whitespace or other special characters?

    4 answers







linux bash variable command-substitution






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 22 at 13:15









Rui F Ribeiro

40.7k1479137




40.7k1479137










asked Feb 6 at 14:28









rjkfsmrjkfsm

264




264




marked as duplicate by Jeff Schaller, Anthony Geoghegan, George Vasiliou, Archemar, Kusalananda Feb 6 at 15:26


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









marked as duplicate by Jeff Schaller, Anthony Geoghegan, George Vasiliou, Archemar, Kusalananda Feb 6 at 15:26


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









  • 5





    try echo "$TEST" | wc -l

    – Bodo
    Feb 6 at 14:33












  • 5





    try echo "$TEST" | wc -l

    – Bodo
    Feb 6 at 14:33







5




5





try echo "$TEST" | wc -l

– Bodo
Feb 6 at 14:33





try echo "$TEST" | wc -l

– Bodo
Feb 6 at 14:33










1 Answer
1






active

oldest

votes


















0














Yep - it was quoting...



echo "$TEST" | wc -l
1050


TY, Bodo!!






share|improve this answer





























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Yep - it was quoting...



    echo "$TEST" | wc -l
    1050


    TY, Bodo!!






    share|improve this answer



























      0














      Yep - it was quoting...



      echo "$TEST" | wc -l
      1050


      TY, Bodo!!






      share|improve this answer

























        0












        0








        0







        Yep - it was quoting...



        echo "$TEST" | wc -l
        1050


        TY, Bodo!!






        share|improve this answer













        Yep - it was quoting...



        echo "$TEST" | wc -l
        1050


        TY, Bodo!!







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 6 at 14:49









        rjkfsmrjkfsm

        264




        264












            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Christian Cage

            How to properly install USB display driver for Fresco Logic FL2000DX on Ubuntu?