I'm trying to have my script read through a file and run function foo on lines that don't start with a "#". So for a file containing:
Code:
# vegetables
squash:squash
tomato:tomatoes
# fruit
apple:apples
papaya:papaya
and a script:
Code:
1 #!/bin/bash
2
3 amount=$1
4 measure=$2
5
6 while read line
7 do
8 a=`echo "$line" | egrep "^#"`
9 #echo $a
10 if [ -z $a ]; then null=
11 else echo $a; fi
12 done < ./ingredients
I get output:
Code:
./sample-measure-conversion: line 10: [: #: binary operator expected
# vegetables
./sample-measure-conversion: line 10: [: #: binary operator expected
# fruit
Any ideas what's up?