I think 'awk' does a better job of cutting than 'cut' but we don't need  
much detail here.
 

Dave Utso
Byte Knowledge







In a message dated 7/1/2014 2:03:05 A.M. Pacific Daylight Time,  
[email protected] writes:

[Sorry  for coming late into this discussion; I was on holiday until 
yesterday,  
and am now working through my e-mail backlog.]

Simone Piccardi  wrote:

> My only use of awk is for something like:
> 
>  awk '{print $N}'
> 
> just because it short. If I need complex  parsing that I cannot do with
> sed/grep/cut/tr I usually write a  program (using my favorite scripting
> language, that's not perl nor  awk...).

Our LPIC-1 training materials include chapters on sed and awk,  which 
instructors are free to use as options. We also cover shell  programming in 
way 
greater depth than is required for the exam, simply  because while the exam 
requires candidates to know the syntax of various  Bash constructs, in real 
life this doesn't really get you anywhere – to  make productive use of the 
shell as a programming language, you also need  to know various programming 
and 
debugging techniques, which we discuss at  some length. After all, you 
can't 
show somebody the contents of the food  cupboard and then expect them to be 
able to cook a three-course gourmet  menu without telling them how to use a 
chef's knife.

The nice thing  about awk is that it has a very simple programming model 
that 
follows  logically from things like shell-style »while read …« loops and 
sed. 
The  other contenders in the field (Perl, Python, Tcl, Ruby, …), while they 
 
have many advantages as programming languages, are much farther removed  
from 
the »Unix philosophy«. You can do useful one-liners with awk in the  middle 
of 
a shell pipeline (which sort-of works in Perl if you're pretty  savvy, and 
doesn't work all that well in Python or Tcl; I don't touch Ruby  with a 10' 
pole so I wouldn't know). Also, awak solves some problems  fairly 
straightforwardly that the standard GNU core tools will punt on –  ever 
tried 
to swap two columns in a file using »cut«?

This is not  to say that I think awk should necessarily be part of the 
LPIC-1 
exam; I'd  just like to mention that we *do* teach people the basics of awk 
in 
order  to prepare them for the real world out there. YMMV.

Anselm
--  
Anselm Lingnau ... Linup Front GmbH ... Linux-, Open-Source- &  
Netz-Schulungen
[email protected], +49(0)6151-9067-103, Fax  -299, 
www.linupfront.de
Linup Front GmbH, Postfach 100121, 64201 Darmstadt,  Germany
Sitz: Weiterstadt (AG Darmstadt, HRB7705), Geschäftsführer: Oliver  Michel
_______________________________________________
lpi-examdev  mailing  list
[email protected]
http://list.lpi.org/cgi-bin/mailman/listinfo/lpi-examdev
_______________________________________________
lpi-examdev mailing list
[email protected]
http://list.lpi.org/cgi-bin/mailman/listinfo/lpi-examdev

Reply via email to