been trying to use see for hours. Can get it working with normal strings but not urls with slashes.
一直试图使用看几个小时。可以使用普通字符串,但不能使用斜杠。
trying to replace /var/www/vhosts/sandbox.modernactivity.co.uk/ to nothing.
试图将/var/www/vhosts/sandbox.modernactivity.co.uk/替换为空。
sed 's%var%%' /Volumes/WEB_BACKUP/backups/ukfast/scripts/INCLUDE_list.txt
spits out //www/vhosts/sandbox.modernactivity.co.uk/restofurl/ and the original was /var/www/vhosts/sandbox.modernactivity.co.uk/restofurl/. Just can't get it to recognise the slashes.
吐出//www/vhosts/sandbox.modernactivity.co.uk/restofurl/,原文是/var/www/vhosts/sandbox.modernactivity.co.uk/restofurl/。只是不能让它识别斜线。
It also doesn't seem to be updating the file?
它似乎也没有更新文件?
any tips welcome!
任何提示欢迎!
2 个解决方案
#1
1
is this what you want?
这是你想要的吗?
sed 's#/var.*\.co\.uk/##' file
test:
测试:
kent$ echo "foo/foo/var/www/vhosts/sandbox.modernactivity.co.uk/bar/bar"|sed 's#/var.*\.co\.uk/##'
foo/foobar/bar
if you want to change the original file with sed, add -i option. like:
如果要使用sed更改原始文件,请添加-i选项。喜欢:
sed -i 's/foo/bar/' file
#2
2
Try:
尝试:
find . -name "yourfile.txt" -print | xargs sed -i "" 's/\/var\/www\/.*\.co\.uk//g'
use \ to escape '/'
用\来逃避'/'
If you are working on Mac use -i ""
如果您正在使用Mac,请使用-i“”
Else on Linux just write -i
另外在Linux上只写-i
#1
1
is this what you want?
这是你想要的吗?
sed 's#/var.*\.co\.uk/##' file
test:
测试:
kent$ echo "foo/foo/var/www/vhosts/sandbox.modernactivity.co.uk/bar/bar"|sed 's#/var.*\.co\.uk/##'
foo/foobar/bar
if you want to change the original file with sed, add -i option. like:
如果要使用sed更改原始文件,请添加-i选项。喜欢:
sed -i 's/foo/bar/' file
#2
2
Try:
尝试:
find . -name "yourfile.txt" -print | xargs sed -i "" 's/\/var\/www\/.*\.co\.uk//g'
use \ to escape '/'
用\来逃避'/'
If you are working on Mac use -i ""
如果您正在使用Mac,请使用-i“”
Else on Linux just write -i
另外在Linux上只写-i