#!/usr/bin/nawk -f # # Usage: unix2coll [-v FS=delim] -v PROFILE=profile field1 [field2 [...]] # # Converts a Unix-style database to Web Collections syntax. # Give as many fieldnames as there are columns in the input # Add FS=delim if the delimiter separating the columns is not # whitespace. For example, to convert the Unix password file # to web collections syntax, do this: # # cat /etc/passwd | # unix2coll -v FS=: -v PROFILE=passwd username password uid \ # gid gcos-field home-dir login-shell BEGIN { for (i = 1; i < ARGC; i++) field[i] = ARGV[i]; ARGC = 1; print ""; } { gsub("\"", """); print "\n"; for (i = 1; i <= NF; i++) printf "\n", field[i], $i; print ""; } END { print "\n"; }