Tuesday, September 28, 2010

How to replace space using sed in shell script

How to replace space using sed in shell script: "Use the + modifer to match one or more occurences of the previous regular expression. It needs to be escaped:
Code:

$ echo '12:Mit 23627 83763 tty message' | sed 's/ \+/:/g'
12:Mit:23627:83763:tty:message

$echo '12:Mit 23627 83763 tty message' | sed 's/ /:/g'| cat -A
12:Mit:23627:::83763:tty::::message$

$ echo '12:Mit 23627 83763 tty message' | sed 's/ +/:/g'
12:Mit 23627 83763 tty message

- Sent using Google Toolbar"

No comments:

Post a Comment