Go Back   Tech Support Forum > Alternative Computing > Linux Support

using the single quote character in an awk print statement

This is a discussion on using the single quote character in an awk print statement within the Linux Support forums, part of the Tech Support Forum category. How do I use a single quote character in an awk statement? For example: awk '{print "gnome-terminal -e \"ssh \'xyz\'\@"$1"\""}'


Reply
 
Thread Tools Search this Thread
Old 05-06-2009, 09:39 AM   #1
Registered Member
 
Join Date: Apr 2009
Posts: 7
OS: ubuntu 8.10



How do I use a single quote character in an awk statement? For example:
Quote:
awk '{print "gnome-terminal -e \"ssh \'xyz\'\@"$1"\""}' file
I can escape the double quote character just fine, but trying to escape the single quote character results in the carret prompt.
Quote:
awk '{print "gnome-terminal -e \"ssh \'xyz\'\@"$1"\""}' file
>
The exact string I'm trying to create is:
Quote:
gnome-terminal -e "ssh 'x y'@$1"
$1 is an ip address from file

__________________
mike909 is offline   Reply With Quote
Old 05-06-2009, 11:18 AM   #2
Registered Member
 
Join Date: Apr 2009
Posts: 7
OS: ubuntu 8.10



solution:
escape x then put in the ascii hex for the ascii character designation of '
[QUOTE]
awk '{print "gnome-terminal -e \"ssh \x27x y\x27@$1"\""}' file
**/QUOTE]
__________________
mike909 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is on
Smilies are on
[IMG] code is on
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Post a Question


» Site Navigation
 > FAQ
  > 10.0.0.2


All times are GMT -7. The time now is 03:42 AM.


Copyright 2001 - 2014, Tech Support Forum

Windows 7 - Windows XP - Windows Vista - Trojan Removal - Spyware Removal - Virus Removal - Networking - Security - Top Web Hosts