I can probably write a shell script to find files only, then pass the list to tar, but I am wondering whether there already is a built-in feature in tar that allows doing just that, in a single command line?
For example, I found the --no-recursion
switch, but when I do:
tar --no-recursion -cvf mydir.tar mydir
It only archives the names of the entries in the directory (including subdirectories!), but it doesn't archive any files.
I also tried:
tar --no-recursion -cvf mydir.tar mydir/*
But while it archives files only, it also archives the names of the subdirectories.
Is there a way to tell tar files only, no directories?
find mydir -type f |xargs cp -t tempdir
and then tar tempdir.find mydir -depth 1 -type f | xargs tar cf mydir.tar
find mydir -maxdepth 1 -type f -exec tar cvf mydir.tar {} +
. The+
puts all the files on the same command line like xargs.