Created
September 10, 2015 00:38
-
-
Save DanCoughlin/ae93115f2d6b3e726664 to your computer and use it in GitHub Desktop.
searching a file provided for key words provided and printing the number of times it has been found.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# give counts for two different variables | |
# for any file passed | |
# and output the values | |
n1=`grep -i $1 $3 | wc -l` | |
n2=`grep -i $2 $3 | wc -l` | |
# output the values | |
echo In file: $3 | |
echo I found $1 $n1 times | |
echo I found $2 $n2 times |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What happens if I run the file with the wrong number of arguments?
$./week3challenge.sh yay example.csv
Can you add error checking to make sure the appropriate number of arguments have been given?