This script should Identify the Latest date file and delete files
which are older than 2 Months from latest date.
bash-3.00$ cat delet_old.sh
#!/bin/bash
touch -d "$(date -d "$(ls -lt | awk 'NR==2{print $6,$7}') 2 months ago")" FILE_MARK &&
find . ! -newer FILE_MARK -exec rm -f {} \;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment