To be quick, this is my command:
echo "user1,user2,user3" | xargs -d, -L 1 usermod -g specialgroup
I want to add multiple existing users to a single group in one single command line. But, the above doesn’t work, however if you put:
echo "user1,user2,user3" | xargs -d, -L 1 echo
It lists you the three users:
user1
user2
user3
Any idea on how I could do it? Even if it’s without the xargs.
Due to a final newline written by
echo,user3becomesuser3\n. I’ve tested your example (removing formatting attempts and extraneousechos from the code), and I’ve found it’s the only problem preventing it from working.Use
echo -n "user1,user2,user3"to avoid final newline.