Math-Tuttle-OSX:279lect08-1 smtuttle$ grep oink pig.txt
oinky
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep moooooo pig.txt
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep oink *.txt
pig.txt:oinky
piggy.txt:oink oink
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep OOOOOMAMA *.txt
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep -n oink pig.txt
1:oinky
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep -n oink *.txt
pig.txt:1:oinky
piggy.txt:1:oink oink
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep grep *.sh
if-and-re1.sh:#quant=`grep -c oink *`
Math-Tuttle-OSX:279lect08-1 smtuttle$ man grep | grep -n grep
6: grep, egrep, fgrep - print lines matching a pattern
152: zgrep, e.g. gzip -cd foo.gz |grep --label=foo something
402: word "grep" somewhere in the "Subject:" field.
404: Large repetition counts in the {n,m} construct may cause grep to use
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep -c oink pig.txt
1
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep -c oink *
#279lect08-1-projected.txt#:0
279lect08-1-projected.txt:0
279lect08-1-projected.txt~:0
279lect08-1-q1-braille.doc:0
279lect08-1-q1-braille.odt:0
279lect08-1-q2-braille.doc:0
279lect08-1-q2-braille.odt:0
279lect08-1-q3-braille.doc:0
279lect08-1-q3-braille.odt:0
279lect08-1-q4-braille.doc:0
279lect08-1-q4-braille.odt:0
279lect08-1.odt:0
279lect08-1.pdf:0
blah.txt:0
clicker-if.sh:0
clicker-if.sh~:1
if-and-re1.sh:2
if-and-re1.sh~:1
pig.txt:1
piggy.txt:1
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep -l oink *
clicker-if.sh~
if-and-re1.sh
if-and-re1.sh~
pig.txt
piggy.txt
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep1.sh
oink
hey looky: (standard
hey looky: input)
Math-Tuttle-OSX:279lect08-1 smtuttle$ # after fix grep in loop
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep1.sh
oink
hey looky: (standard
hey looky: input)
Math-Tuttle-OSX:279lect08-1 smtuttle$ # after saved the fix!
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep1.sh
hey looky: clicker-if.sh~
hey looky: grep1.sh
hey looky: grep1.sh~
hey looky: if-and-re1.sh
hey looky: if-and-re1.sh~
hey looky: pig.txt
hey looky: piggy.txt
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep oink moooooo
grep: moooooo: No such file or directory
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep -s oink moooooo
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep -q oink pig.txt && echo "look ma it worked"
look ma it worked
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep -q oink mooooo && echo "look ma it worked"
grep: mooooo: No such file or directory
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep -qs oink mooooo && echo "look ma it worked"
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep oink grep1.sh
for file in `grep -l oink *`
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep -v oink grep1.sh
#!/bin/bash
do
echo "hey looky: $file"
done
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep -vn oink grep1.sh
1:#!/bin/bash
2:
4:do
5: echo "hey looky: $file"
6:done
Math-Tuttle-OSX:279lect08-1 smtuttle$ wc grep1.sh
5 14 77 grep1.sh
Math-Tuttle-OSX:279lect08-1 smtuttle$ man wc
Math-Tuttle-OSX:279lect08-1 smtuttle$ echo OINK pig.txt
OINK pig.txt
Math-Tuttle-OSX:279lect08-1 smtuttle$ echo OINK >> pig.txt
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep -i oink pig.txt
oinky
OINK
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep -c "CS 279" *.txt
279lect08-1-projected.txt:2
blah.txt:0
pig.txt:1
piggy.txt:1
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep -c "CS 279" .*\.txt$
grep: .*.txt$: No such file or directory
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep -l "CS 279" *.txt
279lect08-1-projected.txt
pig.txt
piggy.txt
Math-Tuttle-OSX:279lect08-1 smtuttle$ grep -n "CS 279" *.txt
279lect08-1-projected.txt:2:CS 279
279lect08-1-projected.txt:27:CS 279 CS 279
pig.txt:2:CS 279
piggy.txt:2:CS 279
Math-Tuttle-OSX:279lect08-1 smtuttle$ iffy1.sh mooooo
Math-Tuttle-OSX:279lect08-1 smtuttle$ iffy1.sh pig.txt
oinky
CS 279
OINK
Math-Tuttle-OSX:279lect08-1 smtuttle$ iffy1.sh mooooo
NO SUCH FILE
Math-Tuttle-OSX:279lect08-1 smtuttle$ iffy1.sh pig.txt
oinky
CS 279
OINK
Math-Tuttle-OSX:279lect08-1 smtuttle$ if-and-re1.sh
Math-Tuttle-OSX:279lect08-1 smtuttle$ if-and-re1.sh moomoo oink argggg whazzup
cow arg:
1: moomoo
pig arg:
2: oink
neither arg:
3: argggg
neither arg:
3: whazzup
# but if put " " around the regular expression pattern...
Math-Tuttle-OSX:279lect08-1 smtuttle$ if-and-re1.sh moomoo oink argggg whazzup
neither arg:
3: moomoo
pig arg:
2: oink
neither arg:
3: argggg
neither arg:
3: whazzup
# but if put NO blank after the [[ in the if-part
Math-Tuttle-OSX:279lect08-1 smtuttle$ if-and-re1.sh moomoo oink argggg whazzup
./if-and-re1.sh: line 8: [[moomoo: command not found
neither arg:
3: moomoo
./if-and-re1.sh: line 8: [[oink: command not found
pig arg:
2: oink
./if-and-re1.sh: line 8: [[argggg: command not found
neither arg:
3: argggg
./if-and-re1.sh: line 8: [[whazzup: command not found
neither arg:
3: whazzup
Math-Tuttle-OSX:279lect08-1 smtuttle$