script help

Knight knightotp at gmail.com
Tue Aug 24 13:26:13 UTC 2010


> On Mon, 23 Aug 2010 10:24:54 -0400
> Tom H wrote:
> 
> > Good answer except for the unnecessary "cat".
> > 
> > $ egrep "Antivirus Pattern" testfile | cut -d " " -f 5 | cut -c 2- | tr
> > -d  '.'

Tom H, thanks for pointing out the unnecessary "cat".
I unfortunately realized it just after I read my message back. ;-)


> But doesn't this assume that the string is on a line on its own with no
> leading or trailing spaces? Or do we know this?
> 
> - Richard.

Richard, you're absolutely right.
To be honest, my example only demonstrates how to use "cut" & "tr". As
it seems the OP already had some sort of solution.(as he hints at grep) 
And is therefore only useful if the string has no data in front. 

Trailing spaces or any other data behind the string will not cause a
problem. As I mentioned in my explanation: cut -c 2-8  will only show
character 2-8 from that portion of the string which is left at that
point. And will leave trailing data out of scope.

But, I have to agree with Cameron that "grep" isn't the right tool to
use in these situations. Sed is.

-- 
Knight Of The Post


Linux Pro or Pro Linux?!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20100824/ce170aa4/attachment.sig>


More information about the ubuntu-users mailing list