2

This is what is have now :

find /home/a -mtime -1 -type f -print0 | xargs -0 tar -pcf $file01| tee -a $LOGFILE 2>&1 

I do understand what tar -cf is but what is tar -pcf?

  • 7
    Whenever you have a question about what a command line tool option means, you can run man command to see the command's manual. In this case running man tar would have given you the answer. – terdon Oct 11 '17 at 12:38
  • obligatory. – will Oct 11 '17 at 16:41
  • run --help first then run man if you need information – phuclv Oct 11 '17 at 16:55
8

The -p flag is not useful when creating an archive (with -c), only when extracting (with -x).


From the GNU tar manual:

-p, --preserve-permissions, --same-permissions

extract information about file permissions (default for superuser)

That's a horrible way of saying "preserve permissions and ownerships".

From the OpenBSD manual:

-p

Preserve user and group ID as well as file mode regardless of the current umask(2). The setuid and setgid bits are only preserved if the user and group ID could be preserved. Only meaningful in conjunction with the -x flag.

  • So it doesn't make sense while creating a tar file? cant one preserve file permission while creating it? – Innov Oct 11 '17 at 9:05
  • 1
    @Innov It is my understanding that they are always preserved when creating an archive. – Kusalananda Oct 11 '17 at 9:06
3

From man tar:

   -p, --preserve-permissions
          extract  information  about  file permissions (default for superuser)

i.e. the -p flag makes sure file permissions (chmod modes) and ownership (user and group) are preserved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.