passing parameters

If I pass parameter that has <space> in between them, is there a simpler way to do it.
Hard coding inside the body of the script does work

$cat test.sh
for i in `fgrep -n $2 $1|cut -f1 -d':'`
....
...

If I pass parameter like the following, it fails

test.sh filename.sql "SOME STRING"

If I hard code test.sh as the following it works:

for i in `fgrep -n "SOME STRING" filename.sql|cut -f1 -d':'`
....
....
josephsonndAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
sunnycoderConnect With a Mentor Commented:
Hi josephsonnd,

Use double quotes inside script too

for i in `fgrep -n "$2" "$1"|cut -f1 -d':'

Cheers!
sunnycoder
0
 
josephsonndAuthor Commented:
Thanks very much!
0
All Courses

From novice to tech pro — start learning today.