dieter
You can use the following to accomplish this: dieter:~$ cat <file> |sed 's/\ /\
/g'
It's OK, but the "cat" only increases system load. A better way is: $ sed 's/\ /\
/g' < file
From Jonathan Wilson to suse-linux-e@lists.suse.com about [SLE] [OT DEVEL]...:
I've got a file that I need to convert all spaces to newlines. According to the O'Rililey Regular Expressions book, it looks like \n is the correct charachter
In 's/regexp/replacement/', \n is only valid in the "regexp", not in the "replacement", see sed(1).
Obviously I don't know what I'm doing. What's the proper way to put in things like \n, \r, and \t with sed?
Just put the corresponding character (not the backslash sequence) into the "replacement". In bash, use <Ctrl-V> to avoid interpretation of the character: Instead of 's/ /\t/g' type 's/ /<Ctrl-v><TAB>/g'. Instead of 's/ /\r/g' type 's/ /<Ctrl-v><Ctrl-m>/g'. Perl's "replacement" syntax is better; backward compatibility is preferred in sed. -- Alexandr.Malusek@imv.liu.se