-2

My .sh file is like below:

#!/bin/sh

FOLDER = '/home/Desktop/myUserName/My_monitored_folder'

ASD= 'cd $FOLDER'
REGEX = '.*xxx.yyy*.*'
$ASD
CMD = 'find -regextype posix-extended -regex $REGEX -mtime +0h10m0s'
$CMD | xargs ls -Blatr** 

My find version is: 4.4.2

when I run this shell file: my purpose is to get some type of files(regex is just for that) that aged in that folder older than 10 minutes. Funny thing is that, -regex without -mtime give me back the files I need. When I use them together, it ends up in ls -Blatr

mtime doesn't function well. indeed mtime doesn't function at all. Could anyone take a look at it? I might be missing something thanks in advance for your time.

Baba
  • 852
  • 1
  • 17
  • 31
akemko
  • 55
  • 10
  • Is this working code? – anubhava Apr 30 '14 at 20:05
  • My version of `find` indicates that the argument to `-mtime` is a simple number with a granularity of days... Granted, it's a bit of an older system. What version of `find` are you using? – twalberg Apr 30 '14 at 21:09
  • Does `man find` tell you that `+0h10m0s` is a valid syntax for `-mtime`? It doesn't on my Debian Wheezy system that also has GNU `find` v4.4.2... – twalberg May 01 '14 at 18:23
  • Sorry for late response, anubhava, works on ubuntu and solaris nicely, only thing is it is not "mtime" but "mmin". my latest code is below. @twalberg, I saw couple usages online. see my answer below. – akemko Jun 03 '14 at 14:27

2 Answers2

0

Without some sample filenames, I cannot directly reproduce the issue but one possible workaround is to leave the regex business to grep.

find --mtime +0h10m0s | egrep $REGEX | xargs ...
merlin2011
  • 71,677
  • 44
  • 195
  • 329
0
#!/bin/sh
OPENDIRECTORY='//My_Monitored_Folder'
REGEXTYPE='posix-extended'
REGEX='.*xxx.yyy*.*'
MINUTESAGED='+15'
CMD="find -regextype $REGEXTYPE -regex $REGEX -mmin $MINUTESAGED"
$OPENDIRECTORY
$CMD | xargs ls -lrt | tr -s " " | cut -d" " -f6-9

last pipes are to just get name and time from terminal log. I hope it helps everyone looking for this subject

akemko
  • 55
  • 10