Try pumping it into the for loop.<div><br></div><div>I have a script (to hand) which takes an input from another script (or command line) and processes it line by line like this:</div><div><br></div><div><div>while read line</div>
<div>do</div><div> echo $line</div><div> someFunctionCall $line</div><div>done</div><div><br></div><div>Could execute like:</div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">sudo cat /etc/passwd | grep '/home' | cut -d : -f 1 | ./newScript.sh</span></div>
<br><div class="gmail_quote">On 24 September 2010 10:18, Evan Ingram <span dir="ltr"><<a href="mailto:evan.ingram@cariss.co.uk">evan.ingram@cariss.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I had come across that link already :)<br>
<br>
It prints all the usernames on seperate lines, what would I have to do<br>
to get them all on oneline... userA userB userC?<br>
<br>
Or is there a way the usermod script can take usernames on different<br>
lines?<br>
<div class="im"><br>
#!/bin/sh<br>
<br>
for USER in<br>
userA<br>
userB<br>
userC<br>
userD<br>
userE<br>
; do<br>
usermod -G USERS $USER<br>
done<br>
<br>
</div>????<br>
<div><div></div><div class="h5"><br>
<br>
On Fri, 2010-09-24 at 10:09 +0100, David Halliday wrote:<br>
> Some discussion on it<br>
> here: <a href="http://www.linuxquestions.org/linux/answers/Networking/How_to_list_all_your_USERs" target="_blank">http://www.linuxquestions.org/linux/answers/Networking/How_to_list_all_your_USERs</a><br>
><br>
><br>
> I did this s few years ago to pull out Active Directory users:<br>
> <a href="http://david-halliday.co.uk/?Linux:Make_/home/" target="_blank">http://david-halliday.co.uk/?Linux:Make_/home/</a><br>
> (I wanted them to have a /home on a linux box so they had FTP, SSH<br>
> and (as a result of a public_html directory) HTTP web hosting easily<br>
> configured for educational purposes. While that wbinfo command is for<br>
> ad users there might be something else but I can't find it yet.<br>
><br>
><br>
> A short answer to your question could be something along the lines of:<br>
> sudo cat /etc/passwd | grep '/home' | cut -d : -f 1<br>
><br>
><br>
><br>
><br>
> On 24 September 2010 09:51, Evan Ingram <<a href="mailto:evan.ingram@cariss.co.uk">evan.ingram@cariss.co.uk</a>><br>
> wrote:<br>
> Hi all<br>
><br>
> I always assumed managing users would be a lot simpler in<br>
> linux, but im<br>
> struggling to find an easy way to add 500+ users into groups.<br>
> Got a<br>
> couple of groups that I need all users to be a part of.<br>
><br>
> #!/bin/sh<br>
><br>
> for USER in userA userB userC userD userE; do<br>
> usermod -G USERS $USER<br>
> done<br>
><br>
> script above should do the trick, but then I'd need to get a<br>
> list of all<br>
> my usernames in the correct format, ie userA userB userC, so<br>
> i'd have to<br>
> use a combination of awk/sed/whatever on /etc/passwd. Is there<br>
> an easier<br>
> way?<br>
><br>
> cheers<br>
><br>
><br>
> _______________________________________________<br>
> Kent mailing list<br>
> <a href="mailto:Kent@mailman.lug.org.uk">Kent@mailman.lug.org.uk</a><br>
> <a href="https://mailman.lug.org.uk/mailman/listinfo/kent" target="_blank">https://mailman.lug.org.uk/mailman/listinfo/kent</a><br>
><br>
><br>
> _______________________________________________<br>
> Kent mailing list<br>
> <a href="mailto:Kent@mailman.lug.org.uk">Kent@mailman.lug.org.uk</a><br>
> <a href="https://mailman.lug.org.uk/mailman/listinfo/kent" target="_blank">https://mailman.lug.org.uk/mailman/listinfo/kent</a><br>
<br>
</div></div>--<br>
Evan Ingram<br>
Technical Manager<br>
CARISS<br>
CARISS House,<br>
205 Westbrook Avenue,<br>
Margate,<br>
CT9 5HS<br>
<br>
01843 823 724<br>
<a href="http://www.cariss.co.uk" target="_blank">www.cariss.co.uk</a><br>
<br>
CARISS is a trading name of CARISS (ICT) Ltd<br>
Company registered in England and Wales<br>
Company Number - 7315254<br>
VAT Number - 856 1229 22<br>
<div><div></div><div class="h5"><br>
<br>
_______________________________________________<br>
Kent mailing list<br>
<a href="mailto:Kent@mailman.lug.org.uk">Kent@mailman.lug.org.uk</a><br>
<a href="https://mailman.lug.org.uk/mailman/listinfo/kent" target="_blank">https://mailman.lug.org.uk/mailman/listinfo/kent</a><br>
</div></div></blockquote></div><br></div>