- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- sed problem with \ ( calling Robin/Harry extra...)
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2002 06:05 AM
тАО01-16-2002 06:05 AM
\x10\x32\x54\xFF,5
and in the following sed the \'s are removed.. do I have to modify the script to add the \\?
sed "s:calledtochange:'$CALLNUM':g" /tmp/4 > /tmp/5
I need the script modified to have
a " placed before and after the \x09\x89\75
ie
"\x10\x32\x54\xFF",5
CALLNUM=`echo $1 | awk '
{
stmp="\\x" "01"
tmp=$1
olenoftmp=length(tmp)
if ( ( olenoftmp % 2 ) != 0 ) {tmp = 0 tmp}
lenoftmp=length(tmp) / 2
for (i = 1; i < lenoftmp+1 ; i++) {
stmp = stmp "\\x" substr(tmp,(i*2),1) substr(tmp,(i*2)-1,1)
}
stmp = stmp "\\x" "FF," olenoftmp
printf stmp
}
'`
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2002 06:10 AM
тАО01-16-2002 06:10 AM
Re: sed problem with \ ( calling Robin/Harry extra...)
CALLNUM=`echo $1 | awk '
{
stmp="\"\x" "01"
tmp=$1
olenoftmp=length(tmp)
if ( ( olenoftmp % 2 ) != 0 ) {tmp = 0 tmp}
lenoftmp=length(tmp) / 2
for (i = 1; i < lenoftmp+1 ; i++) {
stmp = stmp "\x" substr(tmp,(i*2),1) substr(tmp,(i*2)-1,1)
}
stmp = stmp "\x" "FF\"," olenoftmp
printf stmp
}
'`
but the sed is not:
sed "s:calledtochange:$CALLNUM:g" /tmp/4 > /tmp/5
where the final output is
"x01x10x32x54xFF",5
rather than:
"\x01\x10\x32\x54\xFF",5
An echo in the script shows the variable is fine, just a problem with the sed and the \'s
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2002 06:20 AM
тАО01-16-2002 06:20 AM
Re: sed problem with \ ( calling Robin/Harry extra...)
Going back to my (corrected) script:
#!/bin/ksh
echo $1 | nawk '{n=$0;l=length($0)
if (l%2 == 1) {n=0 $0}
printf("\"")
for (i=1;i<=l;i=i+2)
{
s1=substr(n,i,1)
s2=substr(n,i+1,1)
printf ("\\\\x" "%s%s",s2,s1)
}
printf("\\\\x" "FF\", %d\n",l-1)
}'
CALLNUM=`script 012`
echo $CALLNUM
"\x00\x21\xFF", 2
echo abc | sed "s+abc+$CALLNUM+g"
"\x00\x21\xFF", 2
In other words, 4 instead of 2 backslashes are required. Are you seeing the above behaviour?
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2002 06:49 AM
тАО01-16-2002 06:49 AM
Re: sed problem with \ ( calling Robin/Harry extra...)
but the sed is messing up..
no matter how many /'s I put in the awk script the sed doesn't put substitute them at all....
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2002 06:50 AM
тАО01-16-2002 06:50 AM
Re: sed problem with \ ( calling Robin/Harry extra...)
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2002 06:53 AM
тАО01-16-2002 06:53 AM
Solutiontry these changes:
hello=012345678
CALLNUM=`echo $hello | awk '
{
stmp=""
stmp=sprintf("%s%s%sx%s",stmp,"\\\\","\\\\","01")
tmp=$1
olenoftmp=length(tmp)
if ( ( olenoftmp % 2 ) != 0 ) {tmp = 0 tmp}
lenoftmp=length(tmp) / 2
for (i = 1; i < lenoftmp+1 ; i++) {
stmp = sprintf("%s%s%sx%s%s",stmp,"\\\\","\\\\",substr(tmp,(i*2),1),substr(tmp,(
i*2)-1,1))
}
stmp = sprintf("%s%s%sxFF,%d",stmp,"\\\\","\\\\",olenoftmp)
printf stmp
}
'`
echo $CALLNUM
sed "s:calledtochange:$CALLNUM:g" /tmp/4
note the quad slashes and a change to sprintf.
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2002 07:30 AM
тАО01-16-2002 07:30 AM
Re: sed problem with \ ( calling Robin/Harry extra...)
Have you given the changes a try yet?
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2002 07:57 AM
тАО01-16-2002 07:57 AM
Re: sed problem with \ ( calling Robin/Harry extra...)
pereal:root> what /usr/bin/awk
/usr/bin/awk:
$Revision: 82.2 $
The / was still missing after the sed..
Harry's script works..
Later,
Bill