Keeping " in string variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Keeping " in string variable
# 1  
Old 11-20-2009
Keeping " in string variable

Hi again,
in my bash script I have several variable strings like in an array
Code:
STRING_NAME[1]="qqq qqq qqq"
STRING_NAME[2]="www www www"
STRING_NAME[3]="eee eee eee"

This strings are passed to another program as

Code:
${STRING_NAME[$J]}

The problem is the program doesn't recognize the whole string

Code:
"qqq qqq qqq"

but

three time
Code:
qqq

Any help? Thanks
Sarah
# 2  
Old 11-20-2009
Try quoting the variable:

Code:

"${STRING_NAME[$J]}"

# 3  
Old 11-20-2009
Quote:
Originally Posted by scottn
Try quoting the variable:

Code:

"${STRING_NAME[$J]}"

Ok, thank you!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tcsh, using " in a string variable

Hallo, I try to write a tcsh-script which works with ImageMagick. The following command line works perfectly: convert a.tif -pointsize 80 -draw " gravity NorthWest fill black text 0,12 a " b.tif I use the following code in a script (it is a minimal example to show the problem): ... (3 Replies)
Discussion started by: DanielDD
3 Replies

2. Shell Programming and Scripting

How can I find "-" ni the string variable?

I have 100 strings, which have YYYYDDMMHHMMSS in it and only one is YYYYMMDD-HHMMSS. I want to find that dash and replace it. If I check each string, using sed 's/-//g', it shows me warning that - is not found. So I need if ;then sed 's/-//g', but I cannot find correct regular expression to... (11 Replies)
Discussion started by: digioleg54
11 Replies

3. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies

4. Shell Programming and Scripting

tcsh - understanding difference between "echo string" and "echo string > /dev/stdout"

I came across and unexpected behavior with redirections in tcsh. I know, csh is not best for redirections, but I'd like to understand what is happening here. I have following script (called out_to_streams.csh): #!/bin/tcsh -f echo Redirected to STDOUT > /dev/stdout echo Redirected to... (2 Replies)
Discussion started by: marcink
2 Replies

5. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

6. Shell Programming and Scripting

In bash script, how to assign output of a command to a variable while keeping tabs?

Hi, wondering if it's been asked before but didn't find matches from google. Basically I have this line: myvar=$(echo -e "a\tb") Now somehow the '\t' from the echo output gets replaced with white space and then stored in $myvar. It creates a problem for me later to use tab as delimiter to do... (2 Replies)
Discussion started by: birddie
2 Replies

7. Shell Programming and Scripting

Query for replacing a string and keeping the non-replaced content

Hi experts, As i am a novice unix player...so need help for the below query...banged my head from quite a while...:confused: i have a set of html files, in which i need to search for string "Page"(case sensitive) and then replace the same with some numeric code ,say, "XXX1234". Here in... (2 Replies)
Discussion started by: rahulfhp
2 Replies

8. Shell Programming and Scripting

sed - extract string before "/" from variable- linux 2.6.9-89

Hi, I have a FTP script which gets called from a wrapper script that exports a variable having value as: "/export/home/dips/logs/dipsSFTP_file1.log.YYYYMMDDHHMISS". I want to extract the file name "dipsSFTP_file1.log.YYYYMMDDHHMISS" and the dir path "/export/home/dips/logs/" from this... (4 Replies)
Discussion started by: dips_ag
4 Replies

9. Shell Programming and Scripting

input string="3MMTQSZ348GGMZRQWMJM4SD6M";output string="3MMTQ-SZ348-GGMZR-QWMJM-4SD6

input string="3MMTQSZ348GGMZRQWMJM4SD6M" output string="3MMTQ-SZ348-GGMZR-QWMJM-4SD6M" using linux shell script (4 Replies)
Discussion started by: pankajd
4 Replies

10. UNIX for Dummies Questions & Answers

"$variable" is not behaving as a string in my script

Hi All, I am using the below while syntax for reading my file but its not working. Below is the line in my file " 123 rteyu 566" when I use below code the spaces are truncated for 1st variable while read line do x=`echo "$line"|cut -c 1-8` y=`echo "$line"|cut -c 9-15` echo "$x" echo "$y"... (3 Replies)
Discussion started by: yabhi_22
3 Replies
Login or Register to Ask a Question