Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

passing parameters

Posted on 2006-10-27
2
304 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.

840 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