Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×
User Journal

Journal Wolfrider's Journal: HOWTO safe rm in Linux 1

--HOWTO safe rm on Linux (at least):

- Interactive:
o Use Midnight Commander. Works from a text terminal, no GUI needed.
Insert to mark files/dirs, F8 to delete. Never had a misfire, even as root.

- Script (for the paranoid, and want a log):
IF you have a known dir " destdir=/tmp/blah " with a subdir " /tmp/blah/1 "
$ cd $destdir && cd 1 && cd .. && rm -rv 1/* |tee /tmp/rm.txt

- REALLY safe rm, with find:
# find multiple (known) names of files > 40 days old in a given directory and delete them
bkpath="/mnt/bkpdrive"
pathh="$bkpath/work/bkpsys-laptop-p2400-thinkpad-xubuntu-14-04-LTS--64--sda7"
cd $pathh && \
        find $pathh/* \( -name "bkp*gz" -o -name "bkp*bz2" -name "bkp*lzop" -o -name "flist*" \) -type f -mtime +40 -exec /bin/rm -v {} \;

--If you need to delete multiple levels of subdirectories, or dotfiles -- do it interactively, and use MC.

This discussion has been archived. No new comments can be posted.

HOWTO safe rm in Linux

Comments Filter:
  • Gotta say, I don't use rm all that often because I seldom need to but I am particularly fond of Midnight Commander. It's usually one of the first things I install and I end up using it quite often. I was actually given a copy of Norton Commander by Mr. Norton himself in 1987 or 1988. He was handing out disks at a convention that I went to. It was before Symantec bought them. I don't remember quite when that was but I think that was a couple of years later. I don't think Peter wrote Norton Commander himself,

Intel CPUs are not defective, they just act that way. -- Henry Spencer

Working...