[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bash problem with subshell and *



Hi. I'm working on Sarge. I'm parsing a text file when..

cd tmp
ls
aaa bbb ccc ddd

My script parse all file into directory, and grep ^Subject line.

for i in *; do
egrep '^Subject:' $i
done

Subject: Hello Andrea
Subject: Ciao Debiam
Subject: {SpAm?} * Viiagrra * Ciialiis * Leevittra *
Subject: Good OS

Ok? But if I modify my script and store egrep result into VAR

for i in *; do
SUBJECT=$(egrep '^Subject:' $i)
echo $SUBJECT
done

Subject: Hello Andrea
Subject: Ciao Debiam
aaa bbb ccc ddd
Subject: Good OS

In other words subshell expand willcard `*' and shows all files into directory!

How can I fix this problem?

--
Openclose.it - Idee per il software libero
http://www.openclose.it



Reply to: