mysticpolew.blogg.se

Find files by date linux compress old
Find files by date linux compress old











This command, however, has an extensive number of options for finding and listing just the files you. Currently I'm using the script cd /to/top/of/dir/structure tar -cf /path/to/tarfile.tar -files-from /dev/null trick to create empty tar file find. So you want at least find /home/randomcat -mtime +11 -type f -exec gzip \ | bash -xīut in practice you won't speed up a lot your processing. The primary command for listing files is, of course, ls. But now, there is a change in requirement, that I need to find files of certain type, list it and compress each of them to a tar archive and put it to other place. There are many more options, for example to. f is creating an archive with the name '' as supplied in the command above. You can use find command with combination of gzip command to compressed the files older than 1o days by providing parameter mtime with find command. v is providing details of the files that have been archived. Gzip the file older than number of days in Linux Gzip is the utility provided by Operating system linux, unix for gzip the files and reduce the size of the files with compression method or algorithms. And you don't want it to run on anything else than a plain file (not on directories or devices, not on symbolic links). ls -a - lists all files, including the ones whose filenames begin in a dot, which you do not always want to see. Let's break down this command and look into each flag. This will find all files older than 30 days recursively from your working directory if you have permissions to read them.

find files by date linux compress old

This should work on Ubuntu, Suse, Redhat, or pretty much any version of linux.By default, gzip will remove the uncompressed file (since it replaces it with the compressed variant). Hi Satyak, You should be able to use the find with the mtime or the ctime switches Example Code: find. Unlike the commands described above, gzip will encrypt the files 'in place'.

find files by date linux compress old

We’ll use this in order to figure out what files are older than a certain number of days, and then use the rm command to delete them.įind /path/to/files* -mtime +5 -exec rm \ at the end is required to end the command. You just type 'gzip' followed by the name of the file you want to compress.

find files by date linux compress old

The find utility on linux allows you to pass in a bunch of interesting arguments, including one to execute another command on each file.













Find files by date linux compress old