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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Escape Sequence

Status
Not open for further replies.

Neely

Technical User
May 14, 2007
6
IN
What is the proper escape sequence when trying to use a single quote ( ' ).<br>
The backslash ( \ ) does not seem to work.<br>
<br>
ie; echo 'abc' ¦ awk ' { sub ( / \' / , &quot;_&quot; ) ; print } '
 
What about:<br>
<br>
echo '+AFw-047abc+AFw-047' ¦ awk '{sub(&quot;+AFw-047&quot;,&quot;_&quot;);print}'<br>
<br>
+AFw-047 is the ASCII code for simple quote<br>
<br>
<br>
Hope this helps,<br>
Patrice. <p>Patrice ALLAIS<br><a href=mailto:allais@lucent.com>allais@lucent.com</a><br><a href= > </a><br>
 
I have core file that I need to rename. when you run $ file on a core file it tells us what<br>
application died. In this file is the name of the application but it includes<br>
two single quotes at the front and the end like this; 'Order_Manager'. <br>
I need to rename this core file and would like to be able to delete the two single<br>
quotes and set this name to an env. variable.
 
<br>
What about<br>
<br>
file core ¦ awk -F&quot;[ +AFw-t]+-&quot; '{ print substr($NF,2,length($NF)-2); }'<br>
<br>
Hope this helps,<br>
Patrice <p>Patrice ALLAIS<br><a href=mailto:allais@lucent.com>allais@lucent.com</a><br><a href= > </a><br>
 
The file I want to read is /tmp/corefile.out.<br>
When I cat the file It reads 'Order_Manager'.<br>
I wanted to read the file contents and delete the first<br>
and last characters. and save the results back out<br>
to another file /tmp/new.out, which now includes the word Order_Manager.<br>
I tried your suggestion but still get the following error;<br>
ksh: syntax errror at line 1: `(' unexpected.<br>
I guess there is no escape sequence for the single quote.<br>
<br>
I'm still fairly new to AWK, but I think the way I need to <br>
approach this it to figure out how to split the contents<br>
of the file up and somehow delete the first and last characters.<br>
<br>
I appreciate your help in this.<br>

 
HUm... It appears the PIPE sign is removed between core & awk : did you add it? ANother problem may be you use old awk instead of the new one : try with /bin/nawk<br>
<br>
I tried the command on both AIX(awk) and Solaris(nawk) OS, and it works fine.<br>
<br>
I'm not sure I understant what you intend to save in your file new.out : just 'Order_Manager' or the contents of the first file with simple quotes removed around 'Order_Manager'?<br>
<br>
Hope this helps,<br>
Patrice. <p>Patrice ALLAIS<br><a href=mailto:allais@lucent.com>allais@lucent.com</a><br><a href= > </a><br>
 
It Works !! :)<br>
<br>
I worked with it a little more trying to break it down to it's simpliest form. I appreciate<br>
the push in the right direction. I'm sure there are more ways to do this.<br>
<br>
<br>
#! /bin/ksh<br>
#$Id: mailcore.ksh,<br>
#<br>
# Purpose: Read and cleanup the contents of a core file, <br>
# mail the contents of the file, cleanup.<br>
#<br>
#<br>
#The following reads the eleventh field of the core file and sets that value to an env. var<br>
core1=`file core ¦awk '{print $11}'`<br>
#<br>
#The following removes the single quotes from the name<br>
echo $core1 ¦ awk -F
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top