脱出二重引用符とtcshエイリアス
質問
私のしているため、以下のコマンド:
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"。
しかし、引数見積もり、yにエイリアス.というか実際にはダブルクォート?ったもののように'\"'となる"ももいるようです。
を使用していtcshとしています。
解決
ログインしてくださ働による保存の文字列をダブルクォート変数の文字列に囲まれたシングルクォーテーション.ご利用する場合は、変数Iは内部でのシングルクォーテーション.
例:
[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%
ですtcshにOSX
他のヒント
以下のすべての作業 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 ('\'')
ようこれらの解釈されるシェルにより、 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'
何括弧内は独立したサブシェルで.このことは悪いように設定環境変数がほぼ無関係です。
最後に、この例は実際にい:
% t; u; v; w; x; y; z hello world hello world hello world ;hello; world "hello world" hello world hello world
tcsh
は新しい変数 backslash_quote
.だが追加されましたので対応して 6.18.01
(バージョンOS X El Capitan) 6.19
(最新安定したリリース時ります。これにより脱出 '
, "
, は、 `
内部の見積もり。
set backslash_quote
set sentence = 'I\'m a little teapot.'
set sentence2 = "The man said \"hello\""
されない場合、このオプションを使うには、お客様の選択に限られ別の見積もりのシンボル
"The man said "'"'"hello"'"'
または使用しない引用符で布backslashingいます。
The\ man\ said\ \"hello\"
場合はできませんので、別名仕事、書シェルスクリプトchmod+x、どこかでお$PATH(う$HOME/bin):
#!/bin/tcsh
replace -x "must" ...
まったく泳げないんだけど---経験tcshがbashすいということ:
alias t='echo "hello world"' # using single quotes to enclose entire string
alias t=echo\ \"hello\ \ world\" # escape " and <space>
alias t="echo \"hello world\"" # double-quote + escape inner double quotes
そのようなものでtcsh?
そしてその \"
や \'
働いていないときは csh
伝統的な支援などの書式であれば、 tcsh
また無条件に支援し、このような古いスクリプトは正しく動作しない場合があります。
ても答えは、tcshもの set backslash_quote
特;しかしとは異なり、暗黙のう答えることが難しい新しい特徴をかけて食べるという習慣がありtcsh特に、実際に追加 tcsh 少なくとも27年前に最初に記載されてマニュアルページ tcsh.man,v 3.8 1991/07/25 04:50:55
, いわて"新規"をクリック。
backslash_quote (+) If set, backslashes (`\') always quote `\', `'', and `"'. This may make complex quoting tasks easier, but it can cause syntax errors in csh(1) scripts.