1756017 Members
3673 Online
108839 Solutions
New Discussion

Re: AWK difficulties

 
SOLVED
Go to solution
James R. Ferguson
Acclaimed Contributor

Re: AWK difficulties

Hi (again):

> So, I thought by using the awk command to extract only the fields that I wanted would be better than the cut command

If all you are doing is comparing a string of fields, either 'awk' or 'cut' will work as we have described. AWK becomes very powerful when you want to match *and* extract (among other things).

As we say in the Perl community, TMTOWTDI :-)

As for points, thanks. Remember, every response is available for your evaluation and there is no limit to how many total points you can assign in any one thread.

http://forums11.itrc.hp.com/service/forums/helptips.do?#34

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: AWK difficulties

>I thought by using the awk command to extract only the fields that I wanted would be better than the cut command

Yes, awk(1) is much better than the cut(1) command in extracting fields, especially if you have a variable number of spaces/tabs between fields because of this:
Adjacent field delimiters delimit null fields.

>Hein: But be careful that field 9 is indeed unique. I typically 'help' that by adding separators (spaces) around the target string.

That won't help if you have duplicate fields. You may have to scan each field to see if it matches, then use index() that many times.