Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

expect script - automation to insert \ before "

Status
Not open for further replies.

davidbelarus

Programmer
Oct 21, 2011
26
0
0
US
questions.
one of the lines that i pull has special characters, the ".
i know to mask them i precede them with a \.

how do i write script to pull the string in, insert \ in front of " it sees.

david
 
like so?
Code:
% regsub -all \" $s \\\" s2
2
% set s2
abc\"defsabc\"defs
%
where "s" is abc"defsabc"defs

_________________
Bob Rashkin
 
thanks.


i had a little trouble understanding. can you maybe put terms in, like actual strings please. like s is the string below, but what about s2?

the string i will be grabbing is along these lines:
"boot -z "squash" "/home/David/"

 
regsub has four arguments (and, in this case, one option). The arguments are: pattern, souce string, substitution, target string. s2 is the target string. So, given the "-all" option, regsub finds all occurrences of pattern (") in source string and replaces them with substitution (\") and puts the result in target string.

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top