shorten lines
Matt Graham
mhgraham at crow202.org
Mon Mar 16 15:04:02 MST 2015
On 2015-03-16 14:41, Michael Havens wrote:
> I wrote something and was wondering if I could shorten it. I wrote:
> sudo adduser pi audio
> sudo adduser pi video
[more]
>
> And was thinking I could shorten it to:
> sudo adduser pi{ audio video input dialout plugdev tty}
I don't think brace expansion will do what you want here, though I
Could Be Wrong. Try this:
for i in audio video input dialout plugdev tty ; do
sudo adduser pi $i
done
...the "for i in A B C ; do ... done" loop in bash is really useful and
really easy. Works with any list of space-separated items, so if you
want to do something 10 times, "for i in `seq 1 10` ; do ... done" and
Bob's your uncle.
--
Crow202 Blog: http://crow202.org/wordpress
There is no Darkness in Eternity
But only Light too dim for us to see.
More information about the PLUG-discuss
mailing list