I would like to backup all files older than 90 days and greater plus gzip them.  I could execute:  find /path/to/files -type f -mtime 90 -exec gzip "{}" \;   Problem with this command is it includes files 90 days old and not older ones.  So it will gzip June's files but not May's.  Thanks!
43241
I want to find files which are greater than 1 GB and older than 6 months in entire server. How to write a command for this?
70570
I have numerous zip archives, each of which contains a number of zip archives. What is the best way to recursively extract all files contained within this zip archive and its child zip archives, that aren't zip archives themselves?
56248
I have a script that deletes files 7 days or older and then logs them to a folder. It logs and deletes everything correctly but when I open up the log file for viewing, its very sloppy.  log=$HOME/Deleted/$(date)  find $HOME/OldLogFiles/ -type f -mtime +7 -delete -print &gt; "$log"   The log file is difficult to read  Example File Output: (when opened in notepad)  /home/u0146121/OldLogFiles/file1.txt/home/u0146121/OldLogFiles/file2.txt/home/u0146121/OldLogFiles/file3.txt   Is there anyway to log the file nicer and cleaner? Maybe with the Filename, date deleted, and how old it was?  Any suggestions help!
12566
At the moment, if I download a compressed file, it could be any of a .tar.gz archive, a tar.bz2 arhive, a .zip archive or a .gz archive. And each time I do so, I have to remember what the command line options for that program are.  Is there any CLI program where I can just go:  undocompression somefile.??  and let it figure out what format the archive is in? (overly long name used to avoid conflicting with any real program)
14647
I'm struggling to wrap my mind around why the find interprets file modification times the way it does.  Specifically, I don't understand why the -mtime +1 doesn't show files less than 48 hours old.   As an example test I created three test files with different modified dates:   [root@foobox findtest]# ls -l total 0 -rw-r--r-- 1 root root 0 Sep 25 08:44 foo1 -rw-r--r-- 1 root root 0 Sep 24 08:14 foo2 -rw-r--r-- 1 root root 0 Sep 23 08:14 foo3   I then ran find with the -mtime +1 switch and got the following output:  [root@foobox findtest]# find -mtime +1 ./foo3   I then ran find with the -mmin +1440 and got the following output:   [root@foobox findtest]# find -mmin +1440 ./foo3 ./foo2   As per the man page for find, I understand that this is expected behavior:   -mtime n         File’s  data was last modified n*24 hours ago.  See the comments         for -atime to understand how rounding affects the interpretation         of file modification times.   -atime n        File  was  last  accessed n*24 hours ago.  When find figures out        how many 24-hour periods ago the file  was  last  accessed,  any        fractional part is ignored, so to match -atime +1, a file has to        have been accessed at least two days ago.   This still doesn't make sense to me though.  So if a file is 1 day, 23 hours, 59 minutes, and 59 seconds old, find -mtime +1 ignores all that and just treats it like it's 1 day, 0 hours, 0 minutes, and 0 seconds old?  In which case, it's not technically older that 1 day and ignored?   Does... not... compute.
117801
I have 28,000 files of size 6.7 GB in the directory aaa/input. I need create TAR files in the directory aaa/output, such that each TAR file cannot exceed 1.9 GB, so I have to tar the 28,000 files into 4 TAR files (6.7/1.9) as Log_(current date)_01.tar Log_(current date)_02.tar ... etc.  such that each tarball is less than 1.9 GB. Is there a way to do this using a Unix script?
14212
I need to backup a fairly large directory, but I am limited by the size of individual files. I'd like to essentially create a tar.(gz|bz2) archive which is split into 200MB maximum archives. Clonezilla does something similar to this by splitting image backups named like so:  sda1.backup.tar.gz.aa sda1.backup.tar.gz.ab sda1.backup.tar.gz.ac   Is there a way I can do this in one command? I understand how to use the split command, but I'd like to not have to create one giant archive, then split it into smaller archives, as this would double the disk space I'd need in order to initially create the archive.
81035
How can I Get a list of all files modified , say 3 months ago. I checked  question but I was not able to apply it to my scenario. I am trying this now , it seems to be working , but I know there should be a better way using find.  ls -ltR | grep -v '2011-05' | grep -v '2011-06' | grep -v '2011-07' | grep -v '2011-08
117625
I store backups of databases in a directory structure  year/month/day/time/backup_name  an example would be   basics_mini/2012/11/05/012232/RATIONAL.0.db2inst1.NODE0000.20110505004037.001 basics_mini/2012/11/06/012251/RATIONAL.0.db2inst1.NODE0000.20110505003930.001  note that timestamp from the backup file cannot be used. Before the automation testing starts the server time is set to 5.5.2011  So the question is how I can get the latest file if I pass the "base directory" (basics_mini) to some function that I am going to code.  I need to restore the newest database. I do that in php but I wonder if there is a simple shell scripting solution.
19524
I was trying to configure rsync to backup a directory every day with the name of current day.   rsync --verbose --stats --compress --recursive /home/alpha/ /var/backups/alpha/`date +"%a"`   Above command is working fine and is syncing data in Mon directory. But when I copy the same command in cron it is not working  13 16 * * * rsync --verbose --stats --compress --recursive /home/alpha/ /var/backups/alpha/`date +"%a"`   But when I remove `date +"%a"` part from cron it works. Why cron is not executing `date +"%a"`?
87437
I'm trying to beat my head against the syntax of this. I'm getting problems with whitespaces and I can't see if there's a better way to do this.  vardir=/home/user cd $vardir for i in $(ls "$vardir") ; do timestamp="$(stat -c %Y $i)" echo "$i" echo "$timestamp"  done   Result is similar no matter where I quote and I'm not sure what I'm doing wrong:  stat: cannot stat ‘Temporary’: No such file or directory Temporary  stat: cannot stat ‘Items’: No such file or directory Items   My goal is I want to grab the timestamps off of backup directories and touch the current ones to restore the original modified dates.
85705
I have been using find command to find files on my 1 tb hard disk. it takes very long. then I used locate which proved to be faster with regular update using updatedb. But the limitation of locate is that I cannot find files with certain size or modified/created time. can you suggest me any ideas on how to find files at more speed or in that case how to pipe output of locate command in a way that all other information like size, time, etc. can be displayed or redirected to a file.
83311
I want to navigate through all the files in a folder and find out the missing file for a specific date.  Files are partitioned by hour and file name have yyyy-mm-dd-hh formatting.   So between 2017-07-01 and 2017-07-02 there will be 24 files from 2017-07-01-00 through 2017-07-01-23  How can I find missing hourly file if I pass above dates as start and end date?   Appreciate any input!
63084
I use the following command to clear a directory, of files and directories over 30 days old, and move them to an archive directory which I can delete after a few weeks if nobody asks for their files back. The target directory has subdirectories by user name, so will the archive directory.  This is the command I use:  find /path/to/directory/username/ -mtime +30 -exec mv "{}" /path/to/archive/username/ \;   I suggested a modified version of this to answer a question on ask ubuntu, another user edited the code to change the end of line \; for + as it's faster(and more correct?).   However, using + in this way works if the -exec command is ls -lh but not in the actual command that I use. If I try it with + I get an error message:  find: missing argument to '-exec'   I don't understand why it's behaving this way, or what the correct command would be. Please don't just post a command correction, I'd like to understand rather than just follow a suggestion blindly.
78717
I need to search for a file inside a tar.gz file without extracting it. After that, I need to copy the file that was searched (if ever there is) to another folder.  So far I have this, but the copy part of this line gives me an error.  gunzip -c file.tar.gz | tar tvf - | grep filename | -exec cp {} /folder/another_folder \;   Or is there a better way to search for a file inside a tar.gz file without extracting it?
36778
I'm wanting to create a tar archive of a specific directory (with its subdirectories of course). But when I do it, using the tar command, I get a list of files that were included, for example:     a calendar_final/._style.css      a calendar_final/style.css   As you can see, there are two versions of the same file. This goes for every file, and there are many. How do I exclude the temporary files, with the ._ prefix, from the tar archive?
55005
What would be the best way to list 100 first files in a directory sorted by the created timestamp (oldest first). The directory is quite large (around 100000 files). ls piped to head takes an awful long time to complete.   Edit:  Filesystem is ext3. limiting the number of files in the folder is not worth the effort, since this is going to be a rare "clean-up" operation and files are generated by a 3rd party software.   Using file modified time, instead of the creation time provides and acceptable solution.