Thursday, October 16, 2014

Linux find files between dates

touch -t 201409070120.01 first (yyyymmdd-hour)
touch -t 201409080120.01 last (yyyymmdd-hour)

find perl files between date range:

find . -type f -name '*.pl' -newer /root/first ! -newer /root/last -exec ls -s {} \;

remove files with specific extension

find .  \( -name "*.php" -o -name "*.html" -o -iname "*.htm" \) -exec ls -s  {} \; -print -exec rm {} \;

remove files with specific extension and contains some expression:

find .  \( -name "*.php" -o -name "*.html" -o -iname "*.htm" \)  -exec grep -l "some expression"  {} \; -print -exec rm {} \;

find  files and directories between date range:

find .  -type d \( -name cache -o -name logs -o -name stats -o -name webalizer \) -prune -o \( -name "*.php" -o -name "*.html" -o -iname "*.htm" \) -newer /root/first ! -newer /root/last -print




No comments:

Post a Comment