bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: sed


From: Conner, Neil
Subject: RE: sed
Date: Tue, 13 Feb 2007 14:32:28 -0800

Thank you both for your feedback - it's very valuable

The email attachment I sent was corrupted by the mail server so the original 
problem may not have been clear.

INPUT

Thu Jan 18 09:14:52 PST [server: vscan.virus.detected:error]: CIFS: Virus 
Detected - File ONTAP_ADMIN$\vol\vol0\DDD\Ventana\Strattoni\Race 
Stuff\Rumor.exe in share DDD accessed by client CLIENT (111.11.11.111) running 
as user USER is infected. The filer received status message Virus JOKE_SMALLPEN 
Found! and error code [3e8] from vscan (anti-virus) server 222.22.22.22.

READ INPUT

#! /bin/ksh
exec 4< input
read -r -u4 ALERT
print $ALERT

OUTPUT

Thu Jan 18 09:14:52 PST [server: vscan.virus.detected:error]: CIFS: Virus 
Detected - File ONTAP_ADMIN$
ol
ol0\DDD\Ventana\Strattoni\Race Stuff\Rumor.exe in share DDD accessed by client 
CLIENT (111.11.11.111) running as user USER is infected. The filer received 
status message Virus JOKE_SMALLPEN Found! and error code [3e8] from vscan 
(anti-virus) server 222.22.22.22.


--Note that the first two occurrences of the literal \v in the file path have 
been translated into ^K.  (This can be seen in vi but isn't printable here).  
It appears that read -r is interpreting \v in the file path as vertical tab 
-Anyone know why???

--Taking cues from Stephane's first email, my sed script looks like this now 
and is working.

#! /bin/ksh
exec 4< input
read -r -u4 TEMP
ALERT=`echo $TEMP | sed s/^K/\\\\\\\\v/g`
print $ALERT 

8 backslashes was the magic number in this construct, but I know there are 
better ways to write this.

I know this isn't the appropriate forum for questions about ksh, but can answer 
the question about read or point me in the right direction?

Thanks,
Neil

-----Original Message-----
From: Ralf Wildenhues [mailto:address@hidden 
Sent: Tuesday, February 13, 2007 1:31 PM
To: Stephane Chazelas
Cc: Conner, Neil; address@hidden
Subject: Re: sed

Hello Stephane, all,

* Stephane Chazelas wrote on Tue, Feb 13, 2007 at 10:07:36AM CET:
> 
> 1- "echo" is a command to expand the \b, \n, \r... not the
> command to display some text verbatim

Not necessarily.

> echo '\v'
> 
> outputs a vertical tab followed by a line feed.

Not my shell's echo, no.  That outputs backslash v newline.  Not being
able to rely on this is exactly one reason to avoid echo.

> You want the POSIX printf '%s\n' or the ksh/zsh specific print
> -r --.

Yep.  However in the real world (that one that exists next to
standards), existing printf programs can have bugs with long
arguments, or with \045.  If present, printf is certainly
preferable to echo, though.

Cheers,
Ralf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]