LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   creating multiple groups in one line of command (https://www.linuxquestions.org/questions/linux-newbie-8/creating-multiple-groups-in-one-line-of-command-4175587610/)

emiinfo 08-22-2016 05:28 AM

creating multiple groups in one line of command
 
how can i create multiple secondary groups, without script.

can you tell me the command used ?

example:
#]groupadd -r group1 group2 group3


Thanks
Amit

TenTenths 08-22-2016 05:39 AM

Code:

for group in group1 group2 group3;do groupadd -r ${group};done

pan64 08-22-2016 05:54 AM

or you can use xargs:
Code:

echo group1 group2 group3 | xargs -n 1 groupadd -r
(not tested)

emiinfo 08-22-2016 06:04 AM

multiple groups without code
 
Thanks for the reply but I need command not code.

Please help me with some terminal commands, example
]# Groupadd -r





Thanks

TenTenths 08-22-2016 06:08 AM

Quote:

Originally Posted by TenTenths (Post 5594197)
Code:

for group in group1 group2 group3;do groupadd -r ${group};done

Quote:

Originally Posted by pan64 (Post 5594203)
Code:

echo group1 group2 group3 | xargs -n 1 groupadd -r
(not tested)

Quote:

Originally Posted by emiinfo (Post 5594207)
Thanks for the reply but I need command not code.

Please help me with some terminal commands, example
]# Groupadd -r

Those are both command line / terminal commands.

smallpond 08-22-2016 06:33 AM

Groupadd only adds one group at a time.

emiinfo 08-22-2016 07:03 AM

Thanks, ten tenths, smalpond.



Thanks


All times are GMT -5. The time now is 05:12 PM.