Forrest logo
back to the for tool

for:ai:13c23

how do I archive every file in a directory into its own archive?
$ for file in *; do tar -cvzf ${file}.tar.gz ${file}; done
try on your machine

Loop through each file in the directory and create a compressed tar archive for each file.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.

Questions that are answered by this command:

  • how do I archive every file in a directory into its own archive?
back to the for tool