Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 332
  • Last Modified:

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':'`
....
....
0
josephsonnd
Asked:
josephsonnd
1 Solution
 
sunnycoderCommented:
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now