For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > January 2008 > Filtering text output with specific keywords









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Filtering text output with specific keywords
hg@x-formation.com

2008-01-22, 8:22 am

On HP-UX 11.11 nm produces the following output:

_GLOBAL__D___cxa_get_globals_fast| 351224|static|entry |$CODE$
_GLOBAL__F_.._.._.._.._libstdc___v3_src_string_inst.cc_35A49152_BB9F5F62|
107382$
_GLOBAL__F__Z30XMHAVHVMSAPHZKJRRGAOBYPAC
BAMKTP4FILE_74692525|
1073787368|static|$
_GLOBAL__F___udivdi3_FF968C49|1073837976
|static|data |$DATA$
_GLOBAL__I__Z30XMHAVHVMSAPHZKJRRGAOBYPAC
BAMKTP4FILE| 33288|static|
entry


This is outputted a long with several other symbols. However I'd like
to cut out the symbols which are specified by "_GLOBAL__F__",
"_GLOBAL__I__" and "_GLOBAL__D___" and then cuts until the first '|'.

Can anyone come up with some recommendations?

Thanks.

-- Henrik
Alex Fraser

2008-01-22, 7:27 pm


<hg@x-formation.com> wrote in message
news:e4d067b9-7fd2-40bf-acef-40b2f9ab3630@e10g2000prf.googlegroups.com...
[snip]
> This is outputted a long with several other symbols. However I'd like
> to cut out the symbols which are specified by "_GLOBAL__F__",
> "_GLOBAL__I__" and "_GLOBAL__D___" and then cuts until the first '|'.
>
> Can anyone come up with some recommendations?


grep -v '^_GLOBAL__[FID]_' | cut -d \| -f 2- -s

(Outputs lines containing a '|', starting with the first character after the
first '|', except lines starting with 'GLOBAL__F_', 'GLOBAL__I_' or
'GLOBAL__D_'.)

Alex


William Pursell

2008-01-22, 7:27 pm

On Jan 22, 2:17 pm, h...@x-formation.com wrote:
> On HP-UX 11.11 nm produces the following output:
>
> _GLOBAL__D___cxa_get_globals_fast| 351224|static|entry |$CODE$
> _GLOBAL__F_.._.._.._.._libstdc___v3_src_string_inst.cc_35A49152_BB9F5F62|
> 107382$
> _GLOBAL__F__Z30XMHAVHVMSAPHZKJRRGAOBYPAC
BAMKTP4FILE_74692525|
> 1073787368|static|$
> _GLOBAL__F___udivdi3_FF968C49|1073837976
|static|data |$DATA$
> _GLOBAL__I__Z30XMHAVHVMSAPHZKJRRGAOBYPAC
BAMKTP4FILE| 33288|static|
> entry
>
> This is outputted a long with several other symbols. However I'd like
> to cut out the symbols which are specified by "_GLOBAL__F__",
> "_GLOBAL__I__" and "_GLOBAL__D___" and then cuts until the first '|'.
>
> Can anyone come up with some recommendations?


awk.

If you want to output only the characters up to the first
'|' in the lines matching GLOBAL__{I,D,F}__, do:

awk -F '|' '/GLOBAL__[DFI]__/ { print $1 }'

If you mean that you don't want to output those
lines:

awk -F '|' '$0 !~ /GLOBAL__[DFI]__/ { print $1 }'



Henrik Goldman

2008-01-24, 4:34 am


> Can anyone come up with some recommendations?
>


Thank you to both of you. This is exactly what I needed.

-- Henrik


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com