Using chown in a script

I copy some files in a script that I run as root (there are other things
in the script that requires root privileges). So the copy of the file now
belongs to root, but I want it to belong to the user, so I figured
something like this:

cp /a/system/file /a/place/in/my/home/directory/
chown -R <Some user>:<Some Group> /a/place/in/my/home/directory/

Running the env command I noticed my username three times:

Which one should I use for <Some user> above?

For example:
chown -R ${USERNAME}:${USERNAME} /a/place/in/my/home/directory/

I didn't find an environment variable for the groups I belong to, so I
guess I can use the same as for owner, right?

Kind regards

Johnny Rosenberg

ubuntu-users mailing list
Modify settings or unsubscribe at: