How do I compress every file in a directory into its own tar whilst preserving the name for each file?
i.e.
file1.out
file2.out
–>
file1.out.tar.gz
file2.out.tar.gz
linuxtar
How do I compress every file in a directory into its own tar whilst preserving the name for each file?
i.e.
file1.out
file2.out
–>
file1.out.tar.gz
file2.out.tar.gz
Best Answer
Putting every file into a separate tar file doesn't make any sense in this scenario. You can use
gzip
to compress them directly:will result in
file1.out.gz
,file2.out.gz
etc.You would use
tar
only if you would need a compressed archive as a single file.If you ineed need a tar archive for every file, you can create it like so: