LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-14-2010, 11:18 AM   #16
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,256

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686

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"
}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mount.cifs credentials=/path-to-passwd-file not parsing xxx_anuj_xxx Linux - Server 1 11-10-2009 04:44 AM
getent passwd problems carlos23 Linux - Server 1 01-24-2009 02:17 AM
getent passwd only pulls local info - getent group works? epoh Linux - Server 2 03-14-2008 08:56 AM
nss_ldap not working (getent passwd) WindowBreaker Slackware 2 06-27-2006 03:19 AM
getent passwd and wibinfo -u not working bahadur Linux - Networking 0 06-14-2004 01:20 AM


All times are GMT -5. The time now is 08:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration