[CentOS] how to do repetetive command in shell

Thu Oct 21 18:59:11 UTC 2010
Tony Schreiner <tony.schreiner at bc.edu>

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