show stdout containing n with line breaksRemove forced line breaks from fortune output while preserving them for the author lineEcho new line and string beginning tHow to launch a pipe as a persistent processcolor of echo with commandsAdd line breaks to Grep CommandsKeep all line breaks except the last one using awk

Visa National - No Exit Stamp From France on Return to the UK

What are good ways to improve as a writer other than writing courses?

How does The Fools Guild make its money?

How to use grep to search through the --help output?

Max Order of an Isogeny Class of Rational Elliptic Curves is 8?

Ex-contractor published company source code and secrets online

Best gun to modify into a monsterhunter weapon?

Drawing complex inscribed and circumscribed polygons in TikZ

Senior dev discreetly remoting in to computer and watching a coworker

A stranger from Norway wants to have money delivered to me

As a 16 year old, how can I keep my money safe from my mother?

Does the United States guarantee any unique freedoms?

(11 of 11: Meta) What is Pyramid Cult's All-Time Favorite?

Why are the inside diameters of some pipe larger than the stated size?

How do I calculate the difference in lens reach between a superzoom compact and a DSLR zoom lens?

Non-OR journals which regularly publish OR research

English - Acceptable use of parentheses in an author's name

Write an interpreter for *

In a topological space if there exists a loop that cannot be contracted to a point does there exist a simple loop that cannot be contracted also?

Dereferencing a pointer in a 'for' loop initializer creates a segmentation fault

Performance of a branch and bound algorithm VS branch-cut-heuristics

show stdout containing n with line breaks

Word or idiom defining something barely functional

How many different ways are there to checkmate in the early game?



show stdout containing n with line breaks


Remove forced line breaks from fortune output while preserving them for the author lineEcho new line and string beginning tHow to launch a pipe as a persistent processcolor of echo with commandsAdd line breaks to Grep CommandsKeep all line breaks except the last one using awk






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








1















The output from an executable (cURL) contains n. How can such output be displayed with line breaks ?



Say "tCLn1523 memon" is the output from an executable, piping to printf does not show line breaks.



$
$ echo "tCLn1523 memon"
tCLn1523 memon
$
$ printf "tCLn1523 memon"
tCL
1523 memo
$
$ echo "tCLn1523 memon" | xargs -0 printf '%s'
tCLn1523 memon
$
$ echo "tCLn1523 memon" | awk ' printf "%s", $0
tCLn1523 memon
$









share|improve this question


























  • That is because echo does only interpret sequences as n if you use the switch -e.

    – Janka
    8 hours ago











  • @Janka: In this case OP actually wants echo to not interpret the newlines as they are using echo to simulate the curl output that needs to be interpreted.

    – Jesse_b
    8 hours ago


















1















The output from an executable (cURL) contains n. How can such output be displayed with line breaks ?



Say "tCLn1523 memon" is the output from an executable, piping to printf does not show line breaks.



$
$ echo "tCLn1523 memon"
tCLn1523 memon
$
$ printf "tCLn1523 memon"
tCL
1523 memo
$
$ echo "tCLn1523 memon" | xargs -0 printf '%s'
tCLn1523 memon
$
$ echo "tCLn1523 memon" | awk ' printf "%s", $0
tCLn1523 memon
$









share|improve this question


























  • That is because echo does only interpret sequences as n if you use the switch -e.

    – Janka
    8 hours ago











  • @Janka: In this case OP actually wants echo to not interpret the newlines as they are using echo to simulate the curl output that needs to be interpreted.

    – Jesse_b
    8 hours ago














1












1








1








The output from an executable (cURL) contains n. How can such output be displayed with line breaks ?



Say "tCLn1523 memon" is the output from an executable, piping to printf does not show line breaks.



$
$ echo "tCLn1523 memon"
tCLn1523 memon
$
$ printf "tCLn1523 memon"
tCL
1523 memo
$
$ echo "tCLn1523 memon" | xargs -0 printf '%s'
tCLn1523 memon
$
$ echo "tCLn1523 memon" | awk ' printf "%s", $0
tCLn1523 memon
$









share|improve this question
















The output from an executable (cURL) contains n. How can such output be displayed with line breaks ?



Say "tCLn1523 memon" is the output from an executable, piping to printf does not show line breaks.



$
$ echo "tCLn1523 memon"
tCLn1523 memon
$
$ printf "tCLn1523 memon"
tCL
1523 memo
$
$ echo "tCLn1523 memon" | xargs -0 printf '%s'
tCLn1523 memon
$
$ echo "tCLn1523 memon" | awk ' printf "%s", $0
tCLn1523 memon
$






bash echo newlines






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 8 hours ago









Kusalananda

159k18 gold badges313 silver badges500 bronze badges




159k18 gold badges313 silver badges500 bronze badges










asked 8 hours ago









SOUserSOUser

19510 bronze badges




19510 bronze badges















  • That is because echo does only interpret sequences as n if you use the switch -e.

    – Janka
    8 hours ago











  • @Janka: In this case OP actually wants echo to not interpret the newlines as they are using echo to simulate the curl output that needs to be interpreted.

    – Jesse_b
    8 hours ago


















  • That is because echo does only interpret sequences as n if you use the switch -e.

    – Janka
    8 hours ago











  • @Janka: In this case OP actually wants echo to not interpret the newlines as they are using echo to simulate the curl output that needs to be interpreted.

    – Jesse_b
    8 hours ago

















That is because echo does only interpret sequences as n if you use the switch -e.

– Janka
8 hours ago





That is because echo does only interpret sequences as n if you use the switch -e.

– Janka
8 hours ago













@Janka: In this case OP actually wants echo to not interpret the newlines as they are using echo to simulate the curl output that needs to be interpreted.

– Jesse_b
8 hours ago






@Janka: In this case OP actually wants echo to not interpret the newlines as they are using echo to simulate the curl output that needs to be interpreted.

– Jesse_b
8 hours ago











2 Answers
2






active

oldest

votes


















3














%s does not interpret escape sequences. You need %b for that:



% echo 'tCLn1523 memon' | xargs -0 printf "%b"
tCL
1523 memo

%





share|improve this answer




















  • 1





    Nice one! I still think command substitution would be better than xargs though, no?

    – Jesse_b
    7 hours ago











  • Possibly. In either case the entire output ends up as an argument, and with command substitution the extra xargs step is avoided.

    – muru
    7 hours ago











  • @muru Thanks for your solution ! I wonder how to make awk printf also work, given %b is not available ?

    – SOUser
    7 hours ago











  • You'll probably have to use the input as the format string, after replacing all % with %%

    – muru
    7 hours ago


















1














You probably need to transform double-backslash to backslash as well, otherwise the input format would be ambiguous.



You can write a sed script to translate backslash-letter escapes. This script only translates the escape sequences that it recognizes and otherwise removes the backslash. I've put in support for newline and tab.



… | sed 's/\n/n/g; s/\t/ /; s/\(.)/1/g'


The whitespace in s/\t/ / is a tab character. GNU sed lets you write s/\t/t/.



If you also want octal escapes, use a more advanced tool such as Perl. You can make it parse all the escape sequences that it supports.



… | perl -pe 's/\([0-7]1,3|c.|[oxN][^]+|.)/""\$1""/eeg'





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



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f534881%2fshow-stdout-containing-n-with-line-breaks%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









    3














    %s does not interpret escape sequences. You need %b for that:



    % echo 'tCLn1523 memon' | xargs -0 printf "%b"
    tCL
    1523 memo

    %





    share|improve this answer




















    • 1





      Nice one! I still think command substitution would be better than xargs though, no?

      – Jesse_b
      7 hours ago











    • Possibly. In either case the entire output ends up as an argument, and with command substitution the extra xargs step is avoided.

      – muru
      7 hours ago











    • @muru Thanks for your solution ! I wonder how to make awk printf also work, given %b is not available ?

      – SOUser
      7 hours ago











    • You'll probably have to use the input as the format string, after replacing all % with %%

      – muru
      7 hours ago















    3














    %s does not interpret escape sequences. You need %b for that:



    % echo 'tCLn1523 memon' | xargs -0 printf "%b"
    tCL
    1523 memo

    %





    share|improve this answer




















    • 1





      Nice one! I still think command substitution would be better than xargs though, no?

      – Jesse_b
      7 hours ago











    • Possibly. In either case the entire output ends up as an argument, and with command substitution the extra xargs step is avoided.

      – muru
      7 hours ago











    • @muru Thanks for your solution ! I wonder how to make awk printf also work, given %b is not available ?

      – SOUser
      7 hours ago











    • You'll probably have to use the input as the format string, after replacing all % with %%

      – muru
      7 hours ago













    3












    3








    3







    %s does not interpret escape sequences. You need %b for that:



    % echo 'tCLn1523 memon' | xargs -0 printf "%b"
    tCL
    1523 memo

    %





    share|improve this answer













    %s does not interpret escape sequences. You need %b for that:



    % echo 'tCLn1523 memon' | xargs -0 printf "%b"
    tCL
    1523 memo

    %






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered 7 hours ago









    murumuru

    43.6k5 gold badges108 silver badges181 bronze badges




    43.6k5 gold badges108 silver badges181 bronze badges










    • 1





      Nice one! I still think command substitution would be better than xargs though, no?

      – Jesse_b
      7 hours ago











    • Possibly. In either case the entire output ends up as an argument, and with command substitution the extra xargs step is avoided.

      – muru
      7 hours ago











    • @muru Thanks for your solution ! I wonder how to make awk printf also work, given %b is not available ?

      – SOUser
      7 hours ago











    • You'll probably have to use the input as the format string, after replacing all % with %%

      – muru
      7 hours ago












    • 1





      Nice one! I still think command substitution would be better than xargs though, no?

      – Jesse_b
      7 hours ago











    • Possibly. In either case the entire output ends up as an argument, and with command substitution the extra xargs step is avoided.

      – muru
      7 hours ago











    • @muru Thanks for your solution ! I wonder how to make awk printf also work, given %b is not available ?

      – SOUser
      7 hours ago











    • You'll probably have to use the input as the format string, after replacing all % with %%

      – muru
      7 hours ago







    1




    1





    Nice one! I still think command substitution would be better than xargs though, no?

    – Jesse_b
    7 hours ago





    Nice one! I still think command substitution would be better than xargs though, no?

    – Jesse_b
    7 hours ago













    Possibly. In either case the entire output ends up as an argument, and with command substitution the extra xargs step is avoided.

    – muru
    7 hours ago





    Possibly. In either case the entire output ends up as an argument, and with command substitution the extra xargs step is avoided.

    – muru
    7 hours ago













    @muru Thanks for your solution ! I wonder how to make awk printf also work, given %b is not available ?

    – SOUser
    7 hours ago





    @muru Thanks for your solution ! I wonder how to make awk printf also work, given %b is not available ?

    – SOUser
    7 hours ago













    You'll probably have to use the input as the format string, after replacing all % with %%

    – muru
    7 hours ago





    You'll probably have to use the input as the format string, after replacing all % with %%

    – muru
    7 hours ago













    1














    You probably need to transform double-backslash to backslash as well, otherwise the input format would be ambiguous.



    You can write a sed script to translate backslash-letter escapes. This script only translates the escape sequences that it recognizes and otherwise removes the backslash. I've put in support for newline and tab.



    … | sed 's/\n/n/g; s/\t/ /; s/\(.)/1/g'


    The whitespace in s/\t/ / is a tab character. GNU sed lets you write s/\t/t/.



    If you also want octal escapes, use a more advanced tool such as Perl. You can make it parse all the escape sequences that it supports.



    … | perl -pe 's/\([0-7]1,3|c.|[oxN][^]+|.)/""\$1""/eeg'





    share|improve this answer





























      1














      You probably need to transform double-backslash to backslash as well, otherwise the input format would be ambiguous.



      You can write a sed script to translate backslash-letter escapes. This script only translates the escape sequences that it recognizes and otherwise removes the backslash. I've put in support for newline and tab.



      … | sed 's/\n/n/g; s/\t/ /; s/\(.)/1/g'


      The whitespace in s/\t/ / is a tab character. GNU sed lets you write s/\t/t/.



      If you also want octal escapes, use a more advanced tool such as Perl. You can make it parse all the escape sequences that it supports.



      … | perl -pe 's/\([0-7]1,3|c.|[oxN][^]+|.)/""\$1""/eeg'





      share|improve this answer



























        1












        1








        1







        You probably need to transform double-backslash to backslash as well, otherwise the input format would be ambiguous.



        You can write a sed script to translate backslash-letter escapes. This script only translates the escape sequences that it recognizes and otherwise removes the backslash. I've put in support for newline and tab.



        … | sed 's/\n/n/g; s/\t/ /; s/\(.)/1/g'


        The whitespace in s/\t/ / is a tab character. GNU sed lets you write s/\t/t/.



        If you also want octal escapes, use a more advanced tool such as Perl. You can make it parse all the escape sequences that it supports.



        … | perl -pe 's/\([0-7]1,3|c.|[oxN][^]+|.)/""\$1""/eeg'





        share|improve this answer













        You probably need to transform double-backslash to backslash as well, otherwise the input format would be ambiguous.



        You can write a sed script to translate backslash-letter escapes. This script only translates the escape sequences that it recognizes and otherwise removes the backslash. I've put in support for newline and tab.



        … | sed 's/\n/n/g; s/\t/ /; s/\(.)/1/g'


        The whitespace in s/\t/ / is a tab character. GNU sed lets you write s/\t/t/.



        If you also want octal escapes, use a more advanced tool such as Perl. You can make it parse all the escape sequences that it supports.



        … | perl -pe 's/\([0-7]1,3|c.|[oxN][^]+|.)/""\$1""/eeg'






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 7 hours ago









        GillesGilles

        569k136 gold badges1171 silver badges1684 bronze badges




        569k136 gold badges1171 silver badges1684 bronze badges






























            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%2f534881%2fshow-stdout-containing-n-with-line-breaks%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

            Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

            Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

            In Tikz, how to set a node's label alignment to the left?Rotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?Numerical conditional within tikz keys?TikZ/ERD: node (=Entity) label on the insideLine up nested tikz enviroments or how to get rid of themVertically align a tikzpicture and forestDrawing tikz line in the margin for multiple pagesLongtable, contained tikz, padding, custom columns, and an alignment issueTikZ: define arrow starting position based on style and format node labelAlign node name in Tikz