How to pass two words within double quotes as variable?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to pass two words within double quotes as variable?
# 1  
Old 05-13-2014
How to pass two words within double quotes as variable?

Hi All,

OS - Suse 10
ksh --version
version sh (AT&T Research) 93s+ 2008-01-31

I am passing two words within double quotes ("Application Developer") to script as variable, but script is adding two single quotes between two words like ("Application' 'Developer").

below is simple test script which is part of a bigger script.

dummy.ksh
===========
Code:
#!/usr/bin/ksh
#

title='"Application Developer"'
echo $title

===========

When I ran script in debug mode, I can see echo is returning (echo "Application' 'Developer"), what echo is returning is what getting passed to another script but without two single quotes arourd double quotes..

Code:
user@server:~/tmp> ksh -x dummy.sh
+ title='"Application Developer"'
+ echo '"Application' 'Developer"'
"Application Developer"

I tried different ways what were suggested in several forums, but didn't help me, any idea how can

Thanks in advance
srimitta

Last edited by bartus11; 05-13-2014 at 09:28 AM.. Reason: Please use [code][/code] tags.
# 2  
Old 05-13-2014
try
Code:
[Makarand] # cat dummy.sh
#!/usr/bin/ksh
#
title="Application Developer"
echo "$title"
[Makarand] # ./dummy.sh
+ title=Application Developer
+ echo Application Developer
Application Developer

# 3  
Old 05-13-2014
I didn't get your problem. do you want to pass this double quoted string to another script which you are calling inside your script? Please elaborate ?
# 4  
Old 05-13-2014
wrap $title with double quotes

Code:
$ cat sam.sh
#!/usr/bin/ksh
#
title='"Application Developer"'
echo $title
echo "$title"
$ ksh -x sam.sh
+ title='"Application Developer"'
+ echo '"Application' 'Developer"'
"Application Developer"
+ echo '"Application Developer"'
"Application Developer"
$

# 5  
Old 05-13-2014
[edit] SriniShoo has it. Putting quotes within quotes will not protect your string from splitting -- properly quoting it when you use it will.

I suspect you don't actually want or need the inner quotes as literal quote characters and should dispense with them.

Last edited by Corona688; 05-13-2014 at 12:42 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Spaces in double quotes in variable ?

Hi got this issue and was wondering if someone could please help out ? var='." "' echo $var ." " I 'll get ." " and not ." with 10 spaces in between " Thanks (3 Replies)
Discussion started by: stinkefisch
3 Replies

2. Shell Programming and Scripting

Add double quotes to the words after given pattern

Hi, I have a text file with different results and I would like to add single quotes to the value after the given pattern '=' This would be the original text file: user_id=7492 and key=clickid; user_id=7867 and key=clickid; user_id=8649 and key=clickid; And I would like the output to be... (9 Replies)
Discussion started by: mac-arrow
9 Replies

3. Shell Programming and Scripting

Replace Double quotes within double quotes in a column with space while loading a CSV file

Hi All, I'm unable to load the data using sql loader where there are double quotes within the double quotes As these are optionally enclosed by double quotes. Sample Data : "221100",138.00,"D","0019/1477","44012075","49938","49938/15043000","Television - 22" Refurbished - Airwave","Supply... (6 Replies)
Discussion started by: mlavanya
6 Replies

4. Shell Programming and Scripting

Double quotes and variable proble in echo

HI Guys, I want to echo below line in my file :- lpd | grep AL | nawk '{print "1dLA - " $0} How can i echo same Output (4 Replies)
Discussion started by: pareshkp
4 Replies

5. UNIX for Dummies Questions & Answers

awk for inserting a variable containing single and double quotes

Hi i have to insert the below line into a specific line number of another file export MBR_CNT_PRCP_TYPE_CODES_DEL="'01','02','04','05','49','55','UNK'" I have passed the above line to a variable say ins_line. I have used below command to perform the insert awk 'NR==3{print "'"${ins_line}"'"}1'... (1 Reply)
Discussion started by: sathishteradata
1 Replies

6. Shell Programming and Scripting

Enclose words between double quotes

My input is like this: this is a test line. I want my output to be like this: "this", "is", "a", "test", "line" Any idea how this can be done in Linux? (3 Replies)
Discussion started by: shoaibjameel123
3 Replies

7. Shell Programming and Scripting

How to pass a parameter with double quotes around it to a command

In a bash script, I need to pass a parameter that has space in-between using double quotes as follows: CMD="SomeExecutable" # Parameter that has a space in-between PARAM1="TIMO 2" CMD_IN="--name=\"$PARAM1\"" CMD_OUT=`$CMD $CMD_IN` expected/required command execution:... (4 Replies)
Discussion started by: Timo
4 Replies

8. Shell Programming and Scripting

Using echo to print double quotes along with variable substitution

Hi, I am generating html code using cshell, but i am having one problem while printing double quotes, I need to write following code in file. where $var contains list of web address <a href="$var">$var</a> So i am using echo "<a href="$var">$var</a>" > file.html But with this " in... (4 Replies)
Discussion started by: sarbjit
4 Replies

9. AIX

how to pass variables surrounded in double quotes to awk?

Hi, I'm making progress on this but hung up on one last detail. I'd like to use AWK to pass the system date and time(among other things) to the first line of a file. Here's what I have: BEGIN {TOTALPP = 0;FREEPP=0;USEDPP=0;print "LPAR NAME:",lpar,"DATE:",tdate } I call AWK with the... (4 Replies)
Discussion started by: cruiser
4 Replies

10. Shell Programming and Scripting

Double Quotes within a variable

This is a totally dumb newbie question, but I have not been able to find t he answer in the BASH book or online. I am trying pass a double quoted variable to the command line. variable = "-b \"dc=example,dc=com\"" When I run sh -x the variable comes out as '-b "dc=example,dc=com"' is... (4 Replies)
Discussion started by: burton_1080
4 Replies
Login or Register to Ask a Question