<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi David,<br>
<br>
[ockers@agadez ~]$ echo "this that1 that2 that3 theotherthing" | awk
'{print $NF}'<br>
theotherthing<br>
<br>
[ockers@agadez ~]$ echo "this that1 that2 that3 theotherthing" | awk
'{print $2 "," $3 "," $4}'<br>
that1,that2,that3<br>
<br>
NF means "number of fields" and is a numerical value equal to the
number of whitespace-separated list items. Obviously "theotherthing"
is $5. Also -F command line option to awk indicates the field
separator, by default it uses whitespace as the field separator.<br>
<br>
If you want to do something fancy you should know that awk is very
powerful and supports "for" loops. If you want to know the loop
iterator syntax I can suggest that too, but you didn't ask for that.<br>
<br>
No perl! :) awk is great for simple text processing.<br>
<br>
HTH,<br>
Jim<br>
<pre class="moz-signature" cols="72">--
Jim Ockers, P.Eng. (<a class="moz-txt-link-abbreviated" href="mailto:ockers@ockers.net">ockers@ockers.net</a>)
Contact info: <a class="moz-txt-link-freetext" href="http://www.ockers.ca/pason.html">http://www.ockers.ca/pason.html</a>
</pre>
David L. Willson wrote:
<blockquote
cite="mid:23883695.161286367666127.JavaMail.dlwillson@dlwillson-laptop"
type="cite">
<style type="text/css">p { margin: 0; }</style>
<div
style="font-family: Times New Roman; font-size: 12pt; color: rgb(0, 0, 0);">given
lines of the form:<br>
this that1 that2 that3 theotherthing<br>
<br>
where the field separator is any combination of spaces and tabs<br>
and there may be 0-9 that's<br>
<br>
how do I reliably capture theotherthing, and make a packed,
comma-separated list of all the that's.<br>
<br>
This is where I really wish I'd paid more attention in perl class.<br>
Bonus point for not using any perl... :-)<br>
<br>
David L. Willson<br>
Trainer, Engineer, Enthusiast<br>
MCT MSCE Network+ A+ Linux+ LPIC-1 NovellCLA UbuntuCP<br>
tel://720.333.LANS<br>
Freeing people from the tyranny (or whatevery) of Microsofty-ness<br>
</div>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
clue-tech mailing list
<a class="moz-txt-link-abbreviated" href="mailto:clue-tech@cluedenver.org">clue-tech@cluedenver.org</a>
<a class="moz-txt-link-freetext" href="http://cluedenver.org/mailman/listinfo/clue-tech">http://cluedenver.org/mailman/listinfo/clue-tech</a></pre>
</blockquote>
<br>
<br>
</body>
</html>