Reputation: 6306
My file name 'old' contains '123 abc'. When I use the below sed command in linux terminal:
sed 's:[0-9]+:& &:' <old \> new
new file contains same data as old that is '123 abc'. But output should be '123 123 abc'. I don,t know where i am wrong. Can anyone help me please......
Upvotes: 0
Views: 61
Reputation: 37752
Two small remarks:
+
signno need to use a backslash before the >
sign to pipe the output:
sed 's:[0-9]\+:& &:' old > new
(and a minor change; but not necessary: no need for the <
before the input file; sed knows you will give it a file.)
Upvotes: 1
Reputation: 5298
Change your command to:
sed 's:[0-9]\+:& &:' old > new
OR
sed -r 's:[0-9]+:& &:' old > new
-r
: Use extended regular expressions (in our case, for +
to work as expected)
Upvotes: 1