about abs guide

    xiaoxiao2021-03-25  161

    I tried to remove all newlines in a pipe like this:

    (echo foo; echo bar) | sed -e :a -e N -e '$!ba' -e 's/\n/ /g' | hexdump -C

    Which results on debian squeeze in:

    00000000 66 6f 6f 20 62 61 72 0a |foo bar.| 00000008

    Not removing the trailing newline.

    tr -d '\n' as in How do I remove newlines from a text file? works just fine but isn't sed.

     

    Sorry can't be done using sed, please see:http://sed.sourceforge.net/sedfaq5.html#s5.10and a discussion here: http://objectmix.com/awk/26812-sed-remove-last-new-line-2.html

    Looks like sed will add back the \n if it is present as the last character.

    /
    转载请注明原文地址: https://ju.6miu.com/read-3928.html

    最新回复(0)