+ -
当前位置:首页 → 问答吧 → sed删除特定字符串字符??

sed删除特定字符串字符??

时间:2011-08-23

来源:互联网

bash中

localFile="/home/user/.todo_global";
remoteFile="/home/user/Ubuntu One/todo_global.txt";

changed=`diff $localFile $remoteFile`;

这样会出现文件名有空格, 变量赋值就中断的问题
remoteFile="/home/user/Ubuntu\ One/todo_global.txt";
加一个反斜杠转义也不行
应该如何解决

作者: chrwhy   发布时间: 2011-08-23

changed=`diff "$localFile" "$remoteFile"`;
这样

作者: ChenFengyuan   发布时间: 2011-08-23

不使用引号,直接
引用:
remoteFile=/home/user/Ubuntu\ One/todo_global.txt

作者: 我就是我2   发布时间: 2011-08-23

凡是shell跑的地方,参数都加“”
有时候,还要转义,加\"xxx\"

作者: eexpress   发布时间: 2011-08-23

bash中

localFile="/home/user/.todo_global";
remoteFile="/home/user/Ubuntu One/todo_global.txt";

changed=`diff $localFile $remoteFile`;

这样会出现文件名有空格, 变量赋值就中断的问题
remoteFile="/home/user/Ubuntu\ One/todo_global.txt";
加一个反斜杠转义也不行
应该如何解决

作者: chrwhy   发布时间: 2011-08-23

changed=`diff "$localFile" "$remoteFile"`;
这样

作者: ChenFengyuan   发布时间: 2011-08-23

不使用引号,直接
引用:
remoteFile=/home/user/Ubuntu\ One/todo_global.txt

作者: 我就是我2   发布时间: 2011-08-23

凡是shell跑的地方,参数都加“”
有时候,还要转义,加\"xxx\"

作者: eexpress   发布时间: 2011-08-23