tool http://www.linuxvirtualserver.org/
2017 m. vasario 10 d., penktadienis
2017 m. vasario 8 d., trečiadienis
linux cmd delete files in subdirectories older than x days
Be careful with special file names (spaces, quotes) when piping to rm.
There is a safe alternative - the -delete option:
find /path/to/directory/ -mindepth 1 -mtime +5 -delete
That's it, no separate rm call and you don't need to worry about file names.
Replace -delete with -depth -print to test this command before you run it (-delete implies -depth).
shareimprove this answer
edited May 25 '15 at 18:10
Stephen Kitt
59k9104140
answered May 25 '15 at 16:44
basic6
1,5951018
6
Also use -type f to delete files only (and keep sub directories) – Oleg Mar 4 '16 at 8:44
1
Alternatively, if you want to do the same for all files NEWER than five days: find /path/to/directory/ -mindepth 1 -mtime -5 -delete – zmonteca Apr 19 '16 at 17:29
There is a safe alternative - the -delete option:
find /path/to/directory/ -mindepth 1 -mtime +5 -delete
That's it, no separate rm call and you don't need to worry about file names.
Replace -delete with -depth -print to test this command before you run it (-delete implies -depth).
shareimprove this answer
edited May 25 '15 at 18:10
Stephen Kitt
59k9104140
answered May 25 '15 at 16:44
basic6
1,5951018
6
Also use -type f to delete files only (and keep sub directories) – Oleg Mar 4 '16 at 8:44
1
Alternatively, if you want to do the same for all files NEWER than five days: find /path/to/directory/ -mindepth 1 -mtime -5 -delete – zmonteca Apr 19 '16 at 17:29
2017 m. vasario 6 d., pirmadienis
Užsisakykite:
Pranešimai (Atom)