Re: how to do repetetive command in shell

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Oct 21, 2010, at 2:50 PM, Pintér Tibor wrote:

>
>> USER1="roland"
>> USER2="dany"
>> USER3="kevin"
>>
>>
>> cp -r /opt/$USER1/test /backup/$USER1
>> cp -r /opt/$USER2/test /backup/$USER2
>
> $ for user in one two three four; do echo $user; done
> one
> two
> three
> four
>

or if the list of users is in a file, one per line

$ cat file
roland
dany
kevin
$
$ cat file | while read name
do
     something $name
done

Tony

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos



[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux