Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello All
I'm having a little problem using SED. I can get the SED command to work on the command line but not in a script below is the script I'm using.#!/usr/bin/ksh
logfile=/var/adm/messages.1
searchlog=/monitor/nagios/scripts/MESSAGE.txtif [ ! -e $searchlog ]
then
head -1 $logfile | cut -d'[' -f1|read VAR1
echo "VAR1 = "$VAR1
echo "$VAR1" | cut -d" " -f5|read VAR2
echo "VAR2 = "$VAR2
if [[ $VAR2 = /* ]]
then
echo "VAR1 THEN = "$VAR1
VAR3=`echo $VAR1 | sed 's/\//\\\//g'`
# echo "$VAR3" > $searchlog
echo "VAR3 = "$VAR3
# echo "IN THEN"
else
# echo "$VAR1" > $searchlog
echo "VAR1 = "$VAR1
echo "IN ELSE"
fi
fi
echo "Out Of Loop"This is the output I'm getting.
VAR1 = Feb 24 10:24:18 /usr/lib/snmp/snmpdx:
VAR2 = /usr/lib/snmp/snmpdx:
VAR1 THEN = Feb 24 10:24:18 /usr/lib/snmp/snmpdx:
sed: command garbled: s/\//\\//g
VAR3 =
Out Of LoopAlso here is what I get when I set VAR3 to /usr/lib/snmp/snmpdx:
and run this command echo $VAR3 | sed 's/\//\\\//g'
below is the output.
\/usr\/lib\/snmp\/snmpdx:I have no clue way this is not working any help would be great.
Thanks

replace: (single quotes)
VAR3=`echo $VAR1 | sed 's/\//\\\//g'`with: (double quotes)
VAR3=`echo $VAR1 | sed "s/\//\\\//g"`
Luke Chi

![]() |
Uuencode problem in mail ...
|
convert lowercase to uppe...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |