View Full Version : UNIX file delete?
CeeBee
12-09-2007, 12:58 PM
Hoping u can give som advice?
We have a UNIX server with a shared folder, where each person could dump some of their files on.
I now want to delete some of the old users, and their files to make some space.
Can anybody advise how to delete these folders quickly?
I'm having trouble with the deleting.... I use rm file/folder, or rmdir but if there are files in a folder it does not want to delete.
I've tried using FTP32 to get access to the UNIX box from my windows pc, so I can see the directories and the files, but again, have to manually delete each folder's files before I can delete the folder :eek: u can imagine some directories have a lotta subdirs.
Seems like such a schlep... isn't there easier way to delete the whole folder????
flarkit
12-09-2007, 01:01 PM
Try "rm -r foldername"
BUT BEWARE: there is no "undelete", so deleting subdirectories does occasionally lead to hair-pulling experiences!
CeeBee
12-09-2007, 01:11 PM
great! thanx a lot, I tried and it werk soos a bom!
yip I want the whole directory gone, my hairpulling came from sitting here like an ********* deleting each friggin file so I can delete the dir... duh :eek:
or "rm -rf foldername" to force the delete without confirmation (some Linux/Unix installations require confirmation for the deletion of every file).
koffiejunkie
14-09-2007, 09:48 AM
great! thanx a lot, I tried and it werk soos a bom!
So now you also 'get' the "rm -rf /" joke? :D
rorz0r
14-09-2007, 10:04 AM
Yeah just double check everything before you press enter when using rm -rf... Common kinda mistake would be "rm -rf / home/soandso". That extra space makes a big diff...
willirob
14-09-2007, 01:09 PM
and be very careful if you are root....
nothing like rm -rf * in /
redarrow
14-09-2007, 07:07 PM
Ah yes.. "rm -rf" :D
In my earlier Linux days I once trashed my home directory with this.. :o
I wanted to blank a couple of floppy disks and I figured I knew what I was doing when it came to bash scripting :o ... so I write this nice little script to do it..
Something like this:
#!/bin/bash
mount /dev/fd0 /mnt/floppy
cd /mnt/floppy
rm -rf
cd /mnt
umount /dev/fd0
Ya.. well I know that the flaw in this script is really striking .. but at the time it never occurred to me.. :o
So I insert the first disk and run the script.. like so:
[xx@xx ~]$./cleanfloppy
First problem was this disk was corrupt so it wouldn't mount:
mount: you must specify the filesystem type
Second problem was that /mnt/floppy never existed.. :o (can't remember the exact detail as to what happened to it)
bash: cd: /mnt/floppy: No such file or directory
So of course now the script is still in my home directory and here is where the command "rm -rf" gets executed with 100% efficiency.. :eek:
Now why it never occurred to me at the time to replace the whole "cd /mnt/floppy; rm -rf; cd /mnt" with a simple "rm -rf /mnt/floppy" I'll never know .. :o
Yea.. rm -rf can operate at a nastily fast pace..
dabbler
16-09-2007, 09:53 AM
Just to be safe I have the following alias in my ~/.bashrc file
alias rm='rm -i'
Saved my bacon once or twice :D
find . -mtime 2 -exec rm {} \;
This will delete anything older than 2 days from the current directory.
Check the info/man page for find, to see more options.