Berkeley CSUA MOTD:Entry 29769
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2025/05/24 [General] UID:1000 Activity:popular
5/24    

2004/1/30 [Computer/SW/Unix] UID:29769 Activity:nil
1/29    sed help.  How do I take a file, and replace all newlines/returns with
        spaces, so that a multi-line file becomes one long line?
        ideally, something like sed "s/$\N/ /g", but this doesn't work.
        \_ need you use sed?  tr works too:  cat /etc/motd | tr -d '\n'
           \_ thanks that rocks.
              \- unless you need to batch process a whole lot of files,
                 you should learn to use emacs for this kind of thing.
                 query-replace function or something like
                 C-u 1000 C-xf [set-fill-column] M-q [fill-paragraph] --psb
                 \- i note in passing you need some reasonable understanding
                    of how sed works in terms of the pattern spaces and
                    reading in lines of data to use newline matching correctly
                    (it's like understanding perl chop and chomp issues ...
                    sed normally chops off the newline for you before
                    presenting for processing but then add it back in
                    for the output printing routine). there are a lot
                    of version-dependencies in sed which will also
                    drive you insane. --psb
                    \- since you asked --psb
                     /vol/pub/sed-4.0.8/bin/sed ':a;N;$\!ba;s/\n//g' /etc/motd