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 ( / \' / , "_" ) ; print } '
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.
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.