HOWTO: Find files

1) Type in command line:

find / -name '*.mp3' -o -name '*.ogg'

http://www.computerhope.com/issues/ch000623.htm https://stackoverflow.com/questions/7190565/unix-find-multiple-file-types#7190624

HOWTO: Find files for given time period

a) Find files modified within a date range:

find -newermt 20210101 -not -newermt 20211231 -exec ls -lrht {} \;

https://unix.stackexchange.com/questions/73268/how-to-move-the-files-based-on-year

HOWTO: Find files and sort by modification date

find . -printf "%T@ %Tc %p\n" | sort -n

printf arguments:

%Tk: file's last modification time in the format specified by k.
  @: seconds since Jan. 1, 1970, 00:00 GMT, with fractional part.
  c: locale's date and time (Sat Nov 04 12:02:33 EST 1989).
 %p: file's name.

https://superuser.com/questions/294161/unix-linux-find-and-sort-by-date-modified

HOWTO: Add file extension to all files within current directory

1) Run:

find . -type f -exec mv '{}' '{}'.jpg \;

Find all files (-type f) starting from the current directory (.), apply move command (mv) to each of them. Quotes around {} ensure that filenames with spaces and newlines are properly handled.

http://stackoverflow.com/questions/1108527/recursively-add-file-extension-to-all-files

HOWTO: Find and replace pattern in all files of given file type

find -print0 . -type f -name '*.m' | xargs -0 sed -i \
's/a.example.com/b.example.com/g'

http://stackoverflow.com/questions/1585170/how-to-find-and-replace-all-occurrences-of-a-string-recursively-in-a-directory-t

HOWTO: Find files and directories that were modified today

sudo find /mnt/root/ -mtime -1 -print

HOWTO: Print out only filenames of given file type in current directory only

find ./ -maxdepth 1 -name "*.f90" -printf "%f\n"

HOWTO: Avoid output of error messages “Permission denied…”

find 2>/dev/null <...>  # OR
find 2> >(grep -v 'Permission denied' >&2)

HOWTO: Find executable files only

find ./ -executable -type f

HOWTO: Find files older than given ‘modification time’

find ~/tmp ! -newermt "jan 01, 2021" -ls
find ~/tmp ! -newermt "jan 01, 2021" | xargs rm -frv  // to find and remove

https://serverfault.com/questions/122824/linux-using-find-to-locate-files-older-than-date