Re: [問題] shell的小問題
※ 引述《journeyman@kkcity.com.tw (㊣人笨是沒有藥醫的*)》之銘言:
: ※ 引述《indept.bbs@ptt.cc (真人)》之銘言:
: > 也許我沒講清楚, 我希望在 *.c 中找到 'static int' 之類的東西,
: 有,我看懂了,不用再講一遍。
: > 您的程式如果寫成 go.sh, 當執行
: > $go.sh static int
: > $go.sh static
: 空一格表示兩個參數,你只用$1當然只會得到第一個
: 要解決很簡單,用 $1 $2 就得了
: 不過最好的方法是用 $*
:
您是說將您提供的程式中的 $1 改成 $* 嗎?
我試過了, 沒用
chai:~/temp/tmp2> cat a1.c
static int line1
static line2;
int line2;
chai:~/temp/tmp2> cat go.sh
for f in *.c
do
echo :in $f:
cat $f | grep $*
done
chai:~/temp/tmp2> go.sh static int
:in a1.c:
grep: int: No such file or directory
chai:~/temp/tmp2>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 171.64.92.135
討論串 (同標題文章)
Programming 近期熱門文章
PTT數位生活區 即時熱門文章