script help

Tom H tomh0665 at gmail.com
Mon Aug 23 14:24:54 UTC 2010


On Mon, Aug 23, 2010 at 8:11 AM, Knight <knightotp at gmail.com> wrote:
>
> $ cat testfile | egrep "Antivirus Pattern" | cut -d " " -f 5 | cut -c 2- | tr -d  '.'
>
> Result:
> xyyyz
> xyyzz
> xyyyz
> xyyzz
>
> Explanation:
> 1) cat your file
> 2) egrep a pattern (regular expression mode of grep one could also use regular grep in this case)
> 3) cut --delimiter = space, cut everything except field 5
> 4) cut everything before second character and show till end of line.
> When there's bogus data behind the string make it looks like: cut -c 2-8
> 5) tr -d removes the dots

Good answer except for the unnecessary "cat".

$ egrep "Antivirus Pattern" testfile | cut -d " " -f 5 | cut -c 2- | tr -d  '.'




More information about the ubuntu-users mailing list