On 13Oct2006 03:56, Michael Sullivan <[EMAIL PROTECTED]> wrote:
| #!/bin/bash
You're doing nothing bash specific. Say "#!/bin/sh" and avoid pain on
other systems. Make it a habit.
| while read LINE
It is best to name local variables with lowercase names. "Public"
exports symbols are all caps (eg $DDITOR, $TERM etc) and assigning to an
already exported variable is itself exported. This means you may
inadvertently damage an exported variable for a program your script
calls. By using lower case names (eg "$line") you avoid this pitfall.
| do
| echo "Proccessing $LINE..."
| for x in *,*; do
| echo "Filename: $x"
| cat $x | grep '$LINE'
1: This is your main bug.
Say "$LINE", not '$LINE'.
Your variable is not being expended (single quotes versus double
quotes).
2: Don't go:
cat foo | grep blah
instead go:
grep blah foo
or
grep blah <foo
It is both shorter and faster.
| if [ $? -eq 0 ]; then
If conditions are actually commands.
You can do this:
if grep "$LINE" <"$x" >/dev/null
then
which reads better anyway once you know the idiom. "If the grep finds
something then..."
Finally, "." is a "match any single character" in a regexp.
Try using fgrep instead of grep - it takes a fixed string instead of a
regexp.
Finally, you can put:
set -x
at the start of your script to show you the commands being issued.
It would immediately have revealed your '$LINE' quoting problem.
Cheers,
--
Cameron Simpson <[EMAIL PROTECTED]> DoD#743
http://www.cskk.ezoshosting.com/cs/
I've always liked the one where Foghorn Leghorn paints a face on a string mop
and shoves it into the doghouse while going "Boogaboogabooga!" The dog comes
out yapping and snarling, and Foghorn smacks him across the head with an iron
skillet. - Geoff Miller <[EMAIL PROTECTED]>
To unsubscribe from this list, please email [EMAIL PROTECTED] & you will be
removed.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/LINUX_Newbies/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/LINUX_Newbies/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/