F
F
fokin_nikolay19892015-11-25 11:24:48
linux
fokin_nikolay1989, 2015-11-25 11:24:48

How to delete files from a folder?

Guys tell me how to delete files from a folder for a certain period? Are files for 2012 2013 2014 in the same folder?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
fokin_nikolay1989, 2015-11-25
@fokin_nikolay1989

find /var/spool/asterisk/monitor -mtime +182 -exec rm {} \; and if so? delete files older than 180 days
MaxDukov
Max Max
yes. the only thing - I strongly advise you to do not rm before deleting, but ls for a start - you will see a list of files that fall under the condition

A
abcd0x00, 2015-11-25
@abcd0x00

[[email protected] ~]$ find /tmp -maxdepth 1 -type f -printf "%TY %p\n" | awk '$1 >= 2014{print "rm -f " $2}'
rm -f /tmp/.ktorrent_kde4_1000.lock
rm -f /tmp/.XauthFnlUja
rm -f /tmp/winstone152624632382939548.jar
rm -f /tmp/akuma8236603350544705032jar
rm -f /tmp/jna3326402736412458495jar
rm -f /tmp/.X0-lock
[[email protected] ~]$

Further along the channel, you feed this output to sh.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question