Andrew On Tech

tech tricks, hack, useful links, productivity tips, developers tools review and many more

Multiline processing in sed

Posted by mymuss on July 28, 2008

You want sed to replace backslash-newline to space (i.e. to convert multiline string into a singleline) like this:


param =
     val1, \
     val2, \
     val3

should become


param = val1, val2, val3

The following sed command does the trick

sed -e :a -e '/\\$/N; s/\\\n/ /; ta'

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.