Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Debian GNU/Linux Reference Guide
Prev Home Next

13.3 Awk

Riferimenti per Awk:

  • Effective awk Programming, Terza edizione (O'Reilly)

  • Sed & awk, Seconda edizione (O'Reilly)

  • mawk(1) e gawk(1)

  • info gawk

Esempio di programma breve (crea delle voci di account per newusers):

     #!/usr/bin/awk -f
     # Script per creare un file utilizzabile con il comando 'newusers',
     # a partire da un file che contiene user IDs e passwords sotto forma di:
     # Nome Cognome password
     # Copyright (c) KMSelf Sat Aug 25 20:47:38 PDT 2001
     # Distributed under GNU GPL v 2, or at your option, any later version.
     # This program is distributed WITHOUT ANY WARRANTY.
     
     BEGIN {
         # Assign starting UID, GID
         if ( ARGC > 2 ) {
             startuid = ARGV[1]
             delete ARGV[1]
         }
         else {
             printf( "Usage:  newusers startUID file\n" \
               "  where:\n" \ 
               "    startUID is the starting userid to add, and\n" \
               "    file is an input file in form:\n" \
               "      first_name last_name password\n" \
             )
             exit
         }
     
         infile = ARGV[1]
         printf( "Starting UID: %s\n\n", startuid )
     }
     
     /^#/ { next }
     
     {
         ++record
         first = $1
         last = $2
         passwd = $3
         user= substr( tolower( first ), 1, 1 ) tolower( last )
         uid = startuid + record - 1
         gid = uid
         printf( "%s:%s:%d:%d:%s %s,,/home/%s:/bin/bash\n",  \
             user, passwd, uid, gid, first, last, user \
             )
     }

Due sono i pacchetti che forniscono il POSIX awk in Debian:

  • mawk

    • Priorit�: richiesto

    • Dimensioni da installato: 228

    • Pi� piccolo � molto pi� veloce — ottimo per l'installazione base

    • Esiste un limite di tempo di compilazione

      • NF = 32767

      • sprintf buffer = 1020

  • gawk

    • Priorit�: opzionale

    • Dimensioni da installato: 1708

    • Pi� grande e ricco di funzioni — molte le estensioni implementate

      • versione UNIX System V Release 4

      • awk dei Bell Labs

      • GNU-specifico


Debian GNU/Linux Reference Guide
Prev Home Next

 
 
  Published under the terms of the GNU General Public License Design by Interspire