On Monday 27,February,2012 12:14 AM, Javier Barroso wrote:
On Sun, Feb 26, 2012 at 4:30 PM, lina<lina.lastname@gmail.com> wrote:Hi, sorry a bit off-topic, sed -e 's/\(<[^ ]*>\)\([ ]*\)\(<[^ ]*>\)/\3\2\1/g' GNU Linux is cool Linux GNU cool isNo here ...I don't know why $ echo "GNU linux is cool" | sed -e 's/\(<[^ ]*>\)\([ ]*\)\(<[^ ]*>\)/\3\2\1/g' GNU linux is cool It doesn't work.Remove "<" and">", from substitution, and sustitute * by "\+", and you can use " *" without have to use "[ ]*"
I read it from a book and didn't get why use "<"
sed -e 's/\([^ ]\+\)\( \+\)\([^ ]\+\)/\3\2\1/g'
Thanks, I tried, sed -e 's/\([^ ]\+\) \([^ ]\+\) \([^ ]\+\)/\3 \2 \1/g'
or using extended regular expressions, you can remove all escape stuff : sed -re 's/([^ ]+)( +)([^ ]+)/\3\2\1/g'
Ha ... I didn't realize the -r can be used. sed -re 's/([^ ]+) ([^ ]+) ([^ ]+)/\3 \2 \1/g'
I hope this help
Thanks again for your help. I was a bit lost when reading other's work, ... now better. ^_^
Best regards,