Solved

passing parameters

Posted on 2006-10-27
2
294 Views
Last Modified: 2010-04-21
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
Comment
Question by:josephsonnd
2 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 125 total points
ID: 17820886
Hi josephsonnd,

Use double quotes inside script too

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

Cheers!
sunnycoder
0
 

Author Comment

by:josephsonnd
ID: 17821594
Thanks very much!
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question