A
A
Akhmad Zakhratulaev2019-01-29 21:39:37
bash
Akhmad Zakhratulaev, 2019-01-29 21:39:37

How to add commas to output?

Good day!
Please tell me how to correctly add a command in bash in order to get a list of groups, of which $USER is a member, separated by commas without spaces.
Now I receive

groups $USER
test everyone netac com.app

Need something like this
#команда
root,admin,master,nours,boca

Tried cat grep and the -m switch, didn't work.
Thank you for attention!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitsliputsli, 2019-01-29
@asker13

groups $USER | tr ' ' ','

A
AVKor, 2019-01-29
@AVKor

groups $USER | tr ' ' ',' | cut -d, -f3-

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question