Ok i have a file named directory that contains this:
Computer Science 163 William St
Biology 1 New Plaza
Graduate Center 1 Smith Ave
And i am suposed to write a script that will take a department as a parameter and say if it is a match or not here is what i have so far.
Code:
#!/bin/sh
grep $1 directory
if(grep -w $1 `grep $1 directory` )
then
echo there is a match
else
echo no such department
fi
the problem is that grep returns the whole line and i dont know how to compare that to the parameter. like if i did
search "Biology"
grep "Biology" would return (Biology 1 New Plaza)
i think i need the if statment to compare like this
ie: if("Biology" = "Biology")
any ideas? thanks