【发布时间】:2009-10-31 09:53:20
【问题描述】:
我正在尝试编写我的第一个脚本来搜索名为 test.txt 的文本文件中的给定模式。这是脚本:
#! /bin/csh
echo -n "enter pattern: "
set pattern = $<
foreach word (`cat test`)
echo $word | egrep $pattern
end
当我尝试运行它时,我收到消息 foreach: No match found。我怀疑问题是由 (cat test) 引起的。任何帮助将不胜感激。
【问题讨论】:
-
它按原样为我工作(不添加空格)。
-
所以可能是C shell的问题。
标签: unix shell scripting foreach