Sending a parameter with space to another script in bash

I need to send a variable to another script (BASH) and uset after in this first script. The code goes something like this:

read var
source myscipt.sh $var
echo $var

The problem is that if y put spaces when entering $var after sending it to myscript.sh I only have the first one.

NOTE: In myscript.sh I only use $1 does this have something to do with the problem?

Thanx!!!

Answers


You need to use quotes. Thus var will be considered as only one parameter, even if it contains spaces.

source myscipt.sh "$var"

Need Your Help

Unable to disable links in iframe with jQuery

jquery html iframe click

I want to disable all links inside an iFrame.

How to delete the only cell from UICollectionView with animation (deleteItemsAtIndexPaths)?

ios objective-c uicollectionview uicollectionviewcell

I'm getting an assertion while deleting a single UICollecitonViewCell from UICollectionView.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.