我正在尝试运行以下命令:
replace -x "must " A2input.txt replace -x " a" -f -s ## A2input.txt replace -x to -s ## -a A2input.txt replace -x faith -f "unequivocal" A2input.txt
如果我能把它变成简短而简单的东西,如"a","b","c","d"等,那就太好了......
但是,其中一些参数有引用,这会搞乱别名.有谁知道如何实际逃避双引号?我尝试过'\''和\"之类的东西,但似乎没什么用.
我正在使用tcsh作为我的shell.
以下所有工作都tcsh
可以完成各种结果:
alias t echo hello world # you may not actually need any quotes alias u 'echo "hello world"' # nested quotes of different types alias v echo\ \"hello\ world\" # escape everything alias w echo '\;'hello'";"' world # quote/escape problem areas only alias x 'echo \"hello world\"' # single quote and escape for literal " alias y "echo "\""hello world"\" # unquote, escaped quote, quote ("\"") alias z 'echo '\''hello world'\' # same goes for single quotes ('\'')
要查看shell如何解释这些内容,请运行alias
不带参数:
% alias t (echo hello world) u echo "hello world" v echo "hello world" w (echo \;hello";" world) x echo \"hello world\" y echo "hello world" z echo 'hello world'
括号中的任何内容都在子shell中运行.如果您尝试设置环境变量,这将是不好的,但大多数情况下无关紧要.
最后,这是示例实际执行的操作:
% t; u; v; w; x; y; z hello world hello world hello world ;hello; world "hello world" hello world hello world
我通过将带有双引号的字符串存储在一个变量中并使用单引号括起来的字符串来实现它.当我在单引号内使用变量I up时.
例:
[11:~] phi% [11:~] phi% set text = 'a quote "' [11:~] phi% alias ec echo '$text' [11:~] phi% ec a quote " [11:~] phi% [11:~] phi% alias ec echo this has '$text' [11:~] phi% ec this has a quote " [11:~] phi%
我在OSX上用tcsh测试了这个