Using chown in a script

Gurus Knugum gurus.knugum at gmail.com
Sun Sep 5 17:14:07 UTC 2010


Den 2010-09-05 18:23:57 skrev James Bensley <jwbensley at gmail.com>:

> Is this script going to be used on files owned by all different users
> because you could just write the username in the script;
>
> cp /a/system/file /a/place/in/my/home/directory/
> chown -R me:mygrp /a/place/in/my/home/directory/
>
> Or pass it as an argument?
>
> $./copy_script.sh me mygrp
> cp /a/system/file /a/place/in/my/home/directory/
> chown -R $1:$2 /a/place/in/my/home/directory/
>
Well, I just wanted to make it possible to move the script to another  
computer or use it with on the same computer with another user without  
having to rewrite the script and without needing any arguments.

But someone suggested ${SUDO_USER} and it seems to work.

Thanks for replying.
-- 
Kind regards

Johnny Rosenberg




More information about the ubuntu-users mailing list