I'm trying to remove all files more than 1 days old.Before I execute a script to remove the files,I try to find the files using mtime. however, I face same problem with my command-  My Current date is       Wed Jan 27 11:49:20 BDT 2016   My file lists are-       Jan 25 15:11 25-01-2016.txt             Jan 26 13:05 26-01-2016.txt     Jan 27 02:30 27-01-2016.txt     Jan 25 15:11 dfk-25-01-2016.txt     Jan 26 13:05 dfk-26-01-2016.txt       Jan 27 02:30 dfk-27-01-2016.txt    I thought -mtime +1 was supposed to list all files over a day old.  find /etc/output/*.txt -mtime +1 find /etc/output/*.txt -mtime +0   /output/25-01-2016.txt    /output/dfk-25-01-2016.txt  find /etc/output/*.txt -mtime -1   /output/26-01-2016.txt   /output/27-01-2016.txt   /output/dfk-26-01-2016.txt   /output/dfk-27-01-2016.txt    My desired out output is as followings,  find /etc/output/*.txt -mtime +1   /output/25-01-2016.txt   /output/dfk-25-01-2016.txt  find /etc/output/*.txt -mtime +0   /output/26-01-2016.txt   /output/dfk-26-01-2016.txt   /output/25-01-2016.txt   /output/dfk-25-01-2016.txt
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.
79457
I have the following cron jobs defined.  55  8   *   *   3   /usr/bin/php /home/mark/dev/processes/customClient/events.php &gt; /home/mark/dev/processes/customClient/events-`date +%Y-%m-%d --date='last Wednesday'`-`date +%Y-%m-%d`.csv 0   9   *   *   3   /usr/bin/echo 'The csv for last week, trying my hand at automatiging this' | /usr/bin/mutt &lt;emailaddress&gt; -s 'Events from `date +%Y-%m-%d --date='last Wednesday'`-`date +%Y-%m-%d`' -a '/home/mark/dev/processes/customClient/events-`date +%Y-%m-%d --date='last Wednesday'`-`date +%Y-%m-%d`.csv'   It seems to work properly if I run it the above command directly from the command line. But when I checked the running of the script this morning I got an e-mail stating (I'm paraphrasing because I accidentally deleted them) that the back ticks weren't closed properly.
14457
I'm trying to get rid of everything before the filename ex:  /home/mike/whatever/test_1.txt   leaving only test_1.txt  what would the simplest way?  thanks
49877
I'm trying to use the date command to generate a file timestamp that the date command itself can interpret.  However, the date command does not seem to like its own output, and I am not sure how to work around this.  Case in point:  sh-4.2$ date Fri Jan  3 14:22:19 PST 2014 sh-4.2$ date +%Y%m%dT%H%M 20140103T1422 sh-4.2$ date -d "20140103T1422" Thu Jan  2 23:22:00 PST 2014   date appears to be interpreting the string with an offset of 15 hours.  Are there any known workarounds for this?  Edit: this is not an issue of display:  sh-4.2$ date +%s 1388791096 sh-4.2$ date +%Y%m%dT%H%M 20140103T1518 sh-4.2$ date -d 20140103T1518 +%s 1388737080 sh-4.2$ python Python 3.3.3 (default, Nov 26 2013, 13:33:18)  [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; 1388737080 - 1388791096 -54016 &gt;&gt;&gt; 54016/3600 15.004444444444445 &gt;&gt;&gt;    It's still off by 15 hours when displayed as a unix timestamp.    EDIT #1  Maybe I should pose this question a little differently.  Say I have a list of ISO8601 basic timestamps of the form:   YYYYMMDDThhmm YYYYMMDDThhmmss   What is the simplest way to convert them to the corresponding Unix timestamps?   For example:  - 20140103T1422   = 1388787720 - 20140103T142233 = 1388787753
112075
i've got a remote FTP server where i store some backups via cronjob.  The Problem is that i only got a little amount of space so im doing incremental backups. I want to keep the backups about 14 days.  I don't have any other access to the server except FTP and i don't now how to delete files older than x days. Every file got a name with a date in it  yxzNamezxy-date-y-m-d.tar.bz2 (datev-20100111.tar.bz2(   Hope to get some help here.  Cheers and thanks for the hopefully coming answeres,  Dennis  /Edit  I'm trying to use the curl thing which is mantioned in an answere with this part of code  curl ftp://$FTP_SERVER --user $FTP_USER:$FTP_PASS --list-only &gt; files.tmp declare -a aFiles let iCount=0 exec &lt; files.tmp while read sLine do         aFiles[$iCount]=$sLine         ((iCount++)) done  echo -e "\n Files: \n\n\n" echo ${aFiles[@]}  echo -e "\nfor ...\n\n\n" for sFile in $aFiles do         echo -e "\nFile:" $sFile done   but the secound loop doesn't give me more than 1 filename  Cheers,  Dennis
51757
I'm stuck on how I can go about deleting lines that are newer than given date. Here is a snippet of contents of a file.  buildsave.txt  647919 2013/11/30 647946 2013/11/30 647955 2013/12/01 648266 2013/12/03 648267 2013/12/03 648674 2013/12/04   I would like to remove the lines that are newer than 2013/12/03 leaving only  647919 2013/11/30 647946 2013/11/30 647955 2013/12/01   How can this be done through bash?
106392
To list all the files ending with 10 or 11 or 12 I have tried ls *[10-12] and ls *[10,11,12] but these are not working. I don't know why. Can anyone help me?
113945
I am trying to fetch data between a range of time intervals from the log file. However, the complete data is not fetched for the end date.  Below is the command used:   sed -n '/26/Nov/2018/,/30/Nov/2018/ p' /path/file.log    The data I am having in the above log file is somewhat like:   192.168.0.123 - - [25/Nov/2018:13:24:59 +0530] "Data 1"  192.168.0.123 - - [26/Nov/2018:13:24:59 +0530] "Data 2"  192.168.0.123 - - [26/Nov/2018:13:25:09 +0530] "Data 3"  192.168.0.123 - - [27/Nov/2018:13:25:09 +0530] "Data 4"  192.168.0.123 - - [27/Nov/2018:13:25:11 +0530] "Data 5"  192.168.0.123 - - [27/Nov/2018:13:25:53 +0530] "Data 6"  192.168.0.123 - - [28/Nov/2018:13:25:53 +0530] "Data 7"  192.168.0.123 - - [29/Nov/2018:13:25:53 +0530] "Data 8"  192.168.0.123 - - [30/Nov/2018:13:25:53 +0530] "Data 9"  192.168.0.123 - - [30/Nov/2018:13:25:53 +0530] "Data 10"  192.168.0.123 - - [01/Dec/2018:13:25:53 +0530] "Data 11"  192.168.0.123 - - [01/Dec/2018:13:25:53 +0530] "Data 12"
47018
I use the following command in order to delete only the files that start with DBG and older then two day , but this syntax not print the files that deleted  find /tmp  -type f -mtime +2 -name "DBG*" -exec rm {} \;   How to add to this the find syntax , the print in order to print the deleted files?
82434
This is the script I use:  find /path/backups/ -type f -mtime -2 -printf '%P\n' | rsync -avz --progress --delete --exclude-from=- -e "ssh -p 512" /path/backups/ me@host:/remote/path/server-backups/   This is from the log:  &gt; Jan 21 15:32:01 servername CRON[14654]: (serveruser) CMD (find /path/backups/ -type f -mtime -2 -printf ')   I've tried using cron.d, crontab -e and cron.daily. Both putting the script directly in the crontab file as well as calling a .sh script file. Any ideas how I would go about solving this?
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!
49528
How can two dates be compared in a shell?  Here is an example of how I would like to use this, though it does not work as-is:  todate=2013-07-18 cond=2013-07-15  if [ $todate -ge $cond ]; then     break fi                              How can I achieve the desired result?
72970
I have this command that I run every 24 hours currently.  find /var/www/html/audio -daystart -maxdepth 1 -mtime +1 -type f -name "*.mp3" -exec rm -f {} \;   I would like to run it every 1 hour and delete files that are older than 1 hour. Is this correct:  find /var/www/html/audio -daystart -maxdepth 1 -mtime **+0.04** -type f -name "*.mp3" -exec rm -f {} \;   I am not sure of my use of the decimal number??  Thanks for any corrections.  EDIT  OR could I just use -mmin 60? Is this correct?  EDIT2  I tried your test, good thing you suggested it. I got an empty result. I want all files OLDER than 60mins to be deleted! How can I do this?? Does my command actually do this?
5899
I'm trying to understand why the find command is not deleting files in one particular case. I've got the following command:  find C:\\path\\to\\Pictures\\pmcctv -name cap_*.jpg -o -name cap_*.ogg -o -name cap_*.flv -o -name cap_*.mp4 -o -name cap_*.webm -mtime +7   Which returns the files I would expect:  C:\path\to/Pictures/pmcctv/cap_20160915T193251_620067800.jpg C:\path\to/Pictures/pmcctv/cap_20160915T193322_742708800.jpg C:\path\to/Pictures/pmcctv/cap_20160916T081046_394767500.jpg C:\path\to/Pictures/pmcctv/cap_20160916T081125_615129600.jpg C:\path\to/Pictures/pmcctv/cap_20160916T081129_503678200.jpg C:\path\to/Pictures/pmcctv/cap_20160916T081255_842394600.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161008_693586800.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161012_749396800.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161043_774132200.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161150_497251900.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161154_437379600.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161337_350955300.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161341_452596000.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161412_870774000.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161443_969064400.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161554_468109900.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161558_378086000.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161916_668433100.jpg   Now if I try to run the same command with -delete, the files are not deleted:  find C:\\path\\to\\Pictures\\pmcctv -name cap_*.jpg -o -name cap_*.ogg -o -name cap_*.flv -o -name cap_*.mp4 -o -name cap_*.webm -mtime +7 -delete   I've also tried with -exec rm, but they are also not deleted:  find C:\\path\\to\\Pictures\\pmcctv -name cap_*.jpg -o -name cap_*.ogg -o -name cap_*.flv -o -name cap_*.mp4 -o -name cap_*.webm -mtime +7 -exec rm {} \;   find returns no error and the files are owned by me with permissions 644.  Any idea what could be causing this?  (note: I've cut the commands to make it more readable but normally there's no line break)
49687
This is primarily for Windows 7, but I work in multiple versions and would happy to be able to do it in as many of them as possible.  Currently, when I open Explorer and look at a list of files, the date modified column shows something like:  09/18/2013 10:03  I would like it to display:  09/18/2013 10:03:42  I've tried changing the region and language settings for the short time format from HH:mm to HH:mm:ss, but it says it ignores seconds for that.  Does that mean I'm just out of luck?  And again, I'd like to be able to do this in any other  previous versions of Windows too.  It's useful for me as a developer to be able to see the seconds in a lot of situations.  Minor clarification: I did find , which helped me to improve the file properties display, but I wanted to be able to view the full timestamp for all the files in a folder at once, instead of individually.
5669
If you issue ls -all command some files or directories have the year and some have the time? Why do some show the year while others show the time? Is the time representative of the time the file was created?
58274
I want to run a daily incremental backup and append the day of the week to the file name so I end up with:  backup_mon.bak backup_tue.bak  etc.  Not really bothered about what exactly is appended - 0 - 6 is fine.  How do I go about this?