在tcsh shell中,我有:
set tF = downloadedTwitterWorkingFile.txt
set title = $(sed -n '/<title>/,/<\/title>/p' $tF)
返回此错误:
Illegal variable name.
如何将sed搜索的结果放入变量?
工作解决方案
set tF=downloadedTwitterWorkingFile.txt
wget -O $tF -q https://twitter.com/i/streams/stream/686639666771046414
set title='sed -n '/<title>/,/<\/title>/p;/<\/title>/q' $tF
***with ticks not quotes around full sed statment***
答案 0 :(得分:2)
你可以尝试
set title = `sed -n '/<title>/,/<\/title>/p' $tF `
答案 1 :(得分:-3)
在BASH做:
title=$( sed -n '/<title>/,/<\/title>/p' $tF )
$(
之后和)
由于TCSH不支持$()
,所以等效的是反对(`)。
title=`sed -n '/<title>/,/<\/title>/p' $tF`