Tag Info

New answers tagged

0

find / -newerct ` date +"%D"` -name cy This find cy that was changed (or created) after midnight. the newerXY params: c = change time of the file(you can also try 'B', for birth time but it's not supported on all platforms) t = date format to compare with. Very flexible :) try man find for more information about newerXY


0

for the last 24 hours find wherever -name cy\* -ctime -1 -print If there is no file begining witch cy in wherever, you may avoid backslashig *. since midnight find wherever -daystart -name cy\* -ctime -1 -print Hope this help.


0

Now that you have clarified your question, here is an answer that should meet your clarified question: touch -t `date +%m%d0000` /tmp/midnight find / -type d -newer /tmp/$$ -name cy rm /tmp/midnight


1

$ TODAY="cy`date '+%Y%m%d'`" $ find / -name $TODAY To see the contents of $TODAY: $ echo $TODAY $ cy20140806 If you just want it in YYMMDD format, then: $ TODAY="cy`date '+%y%m%d'`" $ find / -name $TODAY $ echo $TODAY $ cy140806 This works for me on Solaris 10. On your system, it may be different. Run a man date to see the options for your system.


0

You specified -or, that needs to be -o, as other have corrected. You also need parentheses I think (correction on my original post). I'd recommend using %T@ for the format specifier (seconds since 1970) which is cleaner to sort; then you can convert it using date --date="@`find . \\( -iname "*.mp3" -o -iname "*.jpg" \\) -printf '%T@\n' | sort -rn | head ...


2

Also see the following: find . -type f -mtime -1 \( -name '*.mp3' -o -name '*.jpg' \) -printf '%AY-%Am-%Ad %P \n'


5

Something like this should work: find . \( -iname "*.mp3" -o -iname "*.jpg" \) -printf '%TY%Tm%Td %TT %p\n' | sort -r This should find the files that (case-insensitively) find files ending with mp3 or jpg, print out the modification time, then sort it in reverse order. It seems to show both file-types when you run it effectively as two commands: ( find ...


4

With zsh: setopt extendedglob zmodload zsh/stat zstat -F %F +mtime -- **/(#i)*.(mp3|jpg)(Om[1]) Note that it's based on last modification time, the creation time (whatever that means) is generally not readily available on Linux. It doesn't consider hidden files. I you want them, add the D globbing qualifier above.


2

Depending on what you want exactly to do, and the structure of your files, other possibilites may be available, such as : ls -1tq /dir/*/readme.txt | head -n 1 Returns the full name of the most recent readme.txt found in any subdirectory (not recursive) of /dir/ The usage of * as part of the path (not just as part of a filename) often being underknown, I ...


1

For more portability, you can use perl: $ perl -MList::Util=reduce -le ' BEGIN { $dir = "." } opendir DIR,$dir; print shift @{(reduce {$a->[1] > $b->[1] ? $a : $b} map {[$_,(stat($_))[9]]} grep { -d and !/^..?$/ } readdir DIR)} ' .Skype Change $dir to whatever directory you want ...


3

You don't need any elaborate pipelines for this. Moreover, you don't need to find anything - you already know where each file is, you just don't know which of them is newest. This is easily handled. To demo, here's my little test: mkdir ./dir1 ./dir2 ./dir3 for d in 1 2 3 do touch ./dir$d/samefile sleep 1 done That creates the test set. Now, which ...


0

Short answer: look into man find and the 'time' options. This will locate the file(s), then use the -printf option to display the path of the file(s), which then can be used for cd <path> One way to use find and extract DIR of the last accessed file (within the last 24h) in current dir and its sub directories lastAccDir="$(find 2>/dev/null . -type ...


1

To complement @JRFerguson's answer. To obtain a reference file whose modification time is 30 minutes in the past, you can do portably (precision of one second): TZ=ZZZ0 touch -t "$(TZ=ZZZ0:30 date +%Y%m%d%H%M.%S)" /some/ref/file And then do: find . -newer /some/ref/file That only works for intervals of 50 hours: TZ=ZZZ-24:59:59 touch -t ...


0

You can use perl instead: #! /usr/bin/perl use strict; use warnings; use File::Find (); use File::stat; use vars qw(*name); *name = *File::Find::name; my $now = time; File::Find::find({wanted => \&wanted}, '.'); sub wanted { print "$name\n" if stat($_)->mtime > ($now - 30*60) and $name ne "."; } Except OSX or ...


2

AIX's find lacks the nice GNU features. You can work around this easily. Create two "reference" files with timestamps that mark the boundaries of interest: touch -amt 201407251200 myref1 touch -amt 201407251230 myref2 Now do: find . -type f \( -newer myref1 -a ! -newer myref2 \) -exec ls -ld {} + This references a file's mtime or modification time. ...


1

You should use -cmin. From man page of find, -cmin n File’s status was last changed n minutes ago. -ctime n File’s status was last changed n*24 hours ago. See the comments for -atime to understand how rounding affects the interpreta- tion of file status change times.



Top 50 recent answers are included