Linux – Copy and chmod/chown at the same time

bashlinux

I have a log file owned by root that I want to copy into a directory owned by another user for him to analyse it (it must be uncompressed first).

Currently I'd have to

# cp log.xz /home/user/Documents
# chown user:user /home/user/Documents/log.xz

Is there a way to issue both commands at the same time, perhaps with one or more cp options?

Best Answer

The cp man page does not list any options that would allow you to do this just with the CP command. If you are wanting to just issue a command and "walk away", you can put the 2 commands on 1 line separated by a ; to automatically execute the commands in sequence.

cp log.xz /home/user/Documents ; chown user:user /home/user/Documents/log.xz
Related Question