Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

passing parameters

Posted on 2006-10-27
2
Medium Priority
?
326 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
[X]
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
2 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 500 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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…
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…
Suggested Courses

722 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