Re: shorten lines

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Matt Graham
Date:  
To: Main PLUG discussion list
Subject: Re: shorten lines
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.
---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.phxlinux.org/mailman/listinfo/plug-discuss