Reputation:
I can't find the mistake in my command. I want to replace
/home/data/newfiles with /home/data/data1/newfiles
I used
sed -i 's/data/data/data1/g' filename
but it is not working.
Upvotes: 1
Views: 37
Reputation: 203209
$ echo '/home/data/newfiles' | sed 's#\(/home/data\)\(/newfiles\)#\1/data1\2#'
/home/data/data1/newfiles
Upvotes: 1
Reputation: 241768
The replacement string can't contain the separator unbackslashed (neither can the regular expression, but that's not a problem here).
sed -i 's/data/data\/data1/g' filename
or, use a different separator
sed -i 's=data=data/data1=g' filename
Upvotes: 0