Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


Search this Thread
Old 03-01-2012, 03:39 AM   #1
Registered: Aug 2009
Posts: 492

Rep: Reputation: 31
A bash-script question: parameter hand up


One of my script looks as follow:

function error()

echo $1
echo $2
The second one calls the first ine as follow:

. ./

ERRORDAT="number 1"

As I run the I got:
This means the $2 is wrong.

What could be the problem?
Old 03-01-2012, 03:52 AM   #2
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,541
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
You need to double quote:
to avoid bash splitting it into two separate words which become $2 and $3 for the function.
1 members found this post helpful.
Old 03-01-2012, 06:46 AM   #3
Registered: Aug 2009
Posts: 492

Original Poster
Rep: Reputation: 31
indeed. many thanks!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] bash variable as parameter to script atomicdog Linux - Newbie 8 05-16-2011 02:49 AM
bash script position parameter does is not parsing '$1' junust Programming 5 04-08-2010 07:50 PM
bash script for selecting a parameter from list of parameters m4rtin Programming 9 12-21-2009 09:41 AM
Conditional (IF) test in bash sh script - presence of first parameter Critcho Linux - Newbie 6 10-01-2008 12:20 AM
bash programming question - hand over variables to another script ppr:kut Linux - General 5 02-09-2008 10:00 AM

All times are GMT -5. The time now is 02:19 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration