LinuxQuestions.org
Help answer threads with 0 replies.
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 05-04-2022, 02:24 PM   #1
noob555
LQ Newbie
 
Registered: Apr 2022
Posts: 13

Rep: Reputation: 0
How can I extract the group names from the id output?


Hello all,

I belong to these groups in my linux os.

Code:
$ id
uid=1000(davevlz) gid=1000(davevlz) groups=1000(davevlz),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),115(lpadmin),135(sambashare),999(vboxusers)
How can I extract the group names and use a comma as a delimiter to look like this below:

davevlz,davevlz,davevlz,adm,cdrom,sudo,dip,plugdev,lpadmin,sambashare,vboxusers

Thanks in advance
 
Old 05-04-2022, 02:35 PM   #2
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,574

Rep: Reputation: 2534Reputation: 2534Reputation: 2534Reputation: 2534Reputation: 2534Reputation: 2534Reputation: 2534Reputation: 2534Reputation: 2534Reputation: 2534Reputation: 2534

Use "groups" instead of "id"

If you then need to change delimiter from space, "tr" is probably the simplest option.


Last edited by boughtonp; 05-04-2022 at 02:39 PM.
 
1 members found this post helpful.
Old 05-04-2022, 02:47 PM   #3
noob555
LQ Newbie
 
Registered: Apr 2022
Posts: 13

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by boughtonp View Post
Use "groups" instead of "id"

If you then need to change delimiter from space, "tr" is probably the simplest option.

Code:
$ groups | tr " " ","
davevlz,adm,cdrom,sudo,dip,plugdev,lpadmin,sambashare,vboxusers
Thanks a bunch it works!!!

Last edited by noob555; 05-04-2022 at 02:48 PM.
 
  


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
group name is not showing when I do $id but group id exists under /etc/group Manohartk Linux - Newbie 4 07-05-2021 08:10 PM
[SOLVED] I want to extract names with spaces from a list of names! linustalman Linux - General 5 12-02-2011 09:42 AM
Block bitmap for group 416 not in group (block 0) + group descriptors corrupted? quanta Linux - Server 1 12-08-2010 10:40 AM
group: add complete group into other group max_mad SUSE / openSUSE 1 04-12-2006 01:43 AM
Group Admin, Group Root, or God over Group crickett Linux - General 5 07-12-2004 04:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:55 AM.

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
Open Source Consulting | Domain Registration