PDA

View Full Version : Deleting files should include verification, and, what script do you adopt for batch?



jon80
November 13th, 2015, 10:04 AM
I tend to make errors sometimes, and, I am not sure whether it is prudent to use verification in scripting when deleting or whether one should adopt archiving scripts rather than removal scripts. It is possible that data consists of databases and also of large volumes of text or other data, so the scripting problem becomes a relevant administrative task to script.

What is your opinion on this with respect to systems administrations tasks you might have and any scripts you might want to share for reference?

See % rm -i foo

Sourced from https://en.wikipedia.org/wiki/Rm_(Unix).

Habitual
November 13th, 2015, 03:45 PM
Non-interactive shell scripts would ignore "rm -i" environment settings in say ~/.bashrc. so you can't verify.
and if you wrote the script using rm -i *, your script would stop until the prompt was satisfied.
This would break scheduled scripts (via cron)
I archive every day, and then only keep the first of the month for months past.
Except for the current month, I keep every day.

leclerc65
November 13th, 2015, 05:54 PM
I usually do a Find first, then Remove after verification, for example.


sudo find /media/Data -iname '*.appledouble*'
sudo find /media/Data -iname '*.appledouble*' -exec rm -rf {} \;

Bucky Ball
November 13th, 2015, 06:01 PM
Thread moved to Programming Talk.