Create a tar archive called
my-directory/ without the parent directory.
You can use this short tar command.
tar -C my-directory -cvf my-directory.tar .
Or this more verbose tar command.
tar --cd my-directory --create --verbose --file my-directory.tar .
Make sure you include the trailing
., as this tells tar to include everything from the root of the directory once it's done the
--directorytells tar to change (
cd) into the directory before creating, listing, extracting, appending to etc. the archive
--createtells tar to create a new archive
--verbosetells tar to produce verbose output
--filetells tar that the next parameter will be the tar file to create, extract, append to, list, etc.