9

Stuck in separating chars into strings in my approach. Found a working approach but can not understand it

view full story
linux-howto

http://unix.stackexchange.com – I am trying to figure out how to break a string to be on character per line. I.e ahebhaaa to be: a h e b h a a a I tried: $ echo ahebhaaa | sed 's/\(.\)\(.\)/\1\n\2/g' I.e. my intention was "plugin" between chars a new line using capture groups but I get: a he bh aa a I guess this has to do with greedy/non-greedy but adding ?* anywhere in this does not do anything. What am I doing wrong here? Additionally I found that this: echo ahebhaaa | sed 's/[^\n]/&\n/g' Does the job. But I don't understand how it works. What is &? How does the [^\n] work? (HowTos)