find . -mindepth 1 -exec tar -rvf archive.tar {} +
find . -mindepth 1 -type f -exec tar -rvf archive.tar {} ; -exec rm {} ;
find . -mindepth 1 ( -type f -o -type d ) -exec tar -rvf archive.tar {} ; -exec rm -rf {} +
tar tf archive.tar
find . -depth -type d -empty -delete
find . -mindepth 1 -exec tar -rvf archive.tar {} +
Here's what each part of the command does:
find .: Starts searching from the current directory (ain your case).-mindepth 1: Ensures thatfinddoes not include the starting directory itself in its output.-exec tar -rvf archive.tar {} +: Executestarfor each found file or directory ({}) and appends (-r) it to thearchive.tarfile (-vfspecifies verbose and file name). The+at the end ensures thattaris called with as many files as possible at once, which is efficient for handling large numbers of files.
This command recursively finds all files and subfolders starting, adds them to archive.tar, and avoids including the tar file itself in the archive.