grail |
07-14-2010 10:18 AM |
Nice change, but absolutely no need to go to other apps like sed or cut as awk can do it all:
Code:
#!/usr/bin/awk -f
BEGIN{ FS=":"}
{
"groups "$1 | getline grps
split(grps,grp," ")
sec=gensub(".*"grp[3]" ","","1",grps)
gsub(/ /,",",sec)
print "RESULT_START __NAME__:"$1":USID:"$3":COMMENTS:"$5":HOME_DIR:"$6":SHELL:"$7":PRIMARY_GRP:"grp[3]":SECONDARY_GRPS:"sec":RESULT_END"
}
|