希望由本地机器给出变量,然后ssh到远程机器上进行变量替换,具体如下: old="old string" //$old中可能有空格或者tab键 new="new string" //$new中可能有空格或者tab键 ssh a "sed "s/$old/$new/g" test_file" //登陆到机器a上对文件test_file进行内容替换,在ssh中的sed应该如何写呢,关键是变量$old,$new完全由用户给出,是含有空格还是tab并不确定 谢谢各位大侠!
如题: 即有字符串: str="111 222 333" 想将分隔的空格替换为tab 在sco中执行 echo $str | sed -e 's/ /\t/g' 结果为 111t222t333 不是想要的 111 222 333 (中间为tab)
举个例子: 原文件: [code]aaaa bb cc ddd ee f gg hhhhhhhhhhhhhhhhhh[/code] 运行后: [code]aaaa bb cc ddd ee f gg hhhhhhhhhhhhhhhhhh[/code] 多谢多谢!!
举个例子: 原文件: aaaa bb cc ddd ee f gg hhhhhhhhhhhhhhhhhh 目标: aaaa bb cc ddd ee f gg hhhhhhhhhhhhhhhhhh 多谢了!!
想用tab替换&
cat file1
&111111111&222222222&3333333333
sed -e 's/&/\t/g' file1 > file2
vim file2
显示是
111111111 222222222 3333333333
但是上面结果file2实际上是space 1111111 tab space 22222222 tab space 33333333
希望能让file2是
tab 1111111 tab 22222222 tab 33333333
请问下要如何实现