TCL - quotes inside a string assigned to a var


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting TCL - quotes inside a string assigned to a var
# 1  
Old 01-08-2015
TCL - quotes inside a string assigned to a var

I know that

Code:
set line "This is a line."


puts whats between " inside the var line.

But

How do I do the same for

Code:
set line "This is a line "with quotations" inside the string."

# 2  
Old 01-08-2015
With most languages you can normally resolve with single quotes.
"This is a line 'with quotations' inside the string."
# 3  
Old 01-09-2015
Hi.
Quote:
Originally Posted by popeye
How do I do the same for
Code:
set line "This is a line "with quotations" inside the string."

This is one way:
Code:
#!/usr/bin/env tclsh

# @(#) s1     Demonstrate embedded quotes.

puts stdout ""
set version [ info tclversion ]
set message " Hello, world from tclsh ($version)"
puts stdout $message

puts stdout ""
set line "This is a line \"with quotations\" inside the string."
puts $line

producing:
Code:
$ ./s1

 Hello, world from tclsh (8.4)

This is a line "with quotations" inside the string.

See Strings in Tcl
Tcl Crash Course - OpenOCD User's Guide

Best wishes ... cheers, drl
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace double quotes inside the string data for all the columns

Please use code tags Hi, I have input data is below format and n of column in the multiple flat files. the string data has any double quotes(") values replaced to double double quotes for all the columns{""). Also, my input flat file each column string data has carriage of new line too.... (14 Replies)
Discussion started by: SSrini
14 Replies

2. Programming

Replace comma which is not inside brackets,quotes or paranthesis

Hi All, I want to replace the commas which are not inside parenthesis,quotes if input is abc,,lm,(no,pq,rs),{tu,vw,xy},zs,"as,as,fr",'ab,cd,ef' output should be abc lm (no,pq,rs) {tu,vw,xy} zs "as,as,fr" 'ab,cd,ef' I tried this str.replaceAll("\\(.*?\\)|(,)", " "); say my string... (3 Replies)
Discussion started by: preethy
3 Replies

3. Shell Programming and Scripting

Csh , how to set var value into new var, in short string concatenation

i try to find way to make string concatenation in csh ( sorry this is what i have ) so i found out i can't do : set string_buff = "" foreach line("`cat $source_dir/$f`") $string_buff = string_buff $line end how can i do string concatenation? (1 Reply)
Discussion started by: umen
1 Replies

4. Shell Programming and Scripting

Preserve commas inside double quotes (perl)

Hi, I have an input file like this $ cat infile hi,i,"am , sam", y hello ,good, morning abcd, " ef, gh " ,ij no, "good,morning", yes, "good , afternoon" from this file I have to split the fields on basis of comma"," however, I the data present inside double qoutes should be treated as... (3 Replies)
Discussion started by: sam05121988
3 Replies

5. Shell Programming and Scripting

Syntax error piping to bc on command line - works when assigned to var

I have a script which outputs some timing data a line at a time. There are approx. 10 lines echoed, each line looks something like this: 0.741 http://checkip.dyndns.org 94.170.119.226Since I needed to add all the values in the first column, I piped the output to grep, matching and printing the... (7 Replies)
Discussion started by: gencon
7 Replies

6. Shell Programming and Scripting

Use $var within quotes

Hi all, My code reads: foldername=$(basename $PWD) myvar=$(rm -v `ls | grep -vE 'file1|file2|$foldername.ext'` | wc -l) echo "Removed $myvar files" The thing is $foldername won't pick the value stored in 'foldername'. My guess is that the single-quotes are making it read $foldername... (2 Replies)
Discussion started by: Aquila
2 Replies

7. Shell Programming and Scripting

How to ignore delimiters inside the quotes?

Hi Experts, How to ignore any delimiters which is inside the quotes. in awk script. I am having script which counts number of delimiters from the line now i need count delimiters only separators . `grep "14" | cut -d"=" -f2` -F'~'if (NF-1 != v1) ' this command counts number of Tilde... (7 Replies)
Discussion started by: Ganesh Khandare
7 Replies

8. Shell Programming and Scripting

how to remove the assigned value from the string

Hi I have the following assignment in my ksh script: PX_LIST="4119 2390 2294 2776 2897 4099" Is there any sed/awk command which would allow the to remove certain number from this string. Let's say I need to remove PX=2390 from PX_LIST, so the output after deletion will be" PX_LIST="4119 2294... (5 Replies)
Discussion started by: aoussenko
5 Replies

9. Shell Programming and Scripting

sed removing comma inside double quotes

I have a csv file with lines like the followings 123456,"ABC CO., LTD","XXX" 789012,"DEF LIMITED", "XXX" before I bcp this file to database, the comma in "CO.," need to be removed first. My script is cat <filename> | sed 's/"CO.,"/"CO."/g' but it doesn't work. Can anyone here able to... (2 Replies)
Discussion started by: joanneho
2 Replies

10. Shell Programming and Scripting

escaping double-quotes inside the script?

I'm having a strange problem with escaping double-quotes. I have a script that looks like this: #!/bin/bash for HOST in `cat $INFILE | grep -v ^#` do for VFILER in `some_command` do echo " " echo -e '\E The problem with ssh command... (3 Replies)
Discussion started by: GKnight
3 Replies
Login or Register to Ask a Question