UNIX file delete?

CeeBee

Expert Member
Joined
Jul 27, 2006
Messages
2,281
Reaction score
101
Location
Pta mostly
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????
 
Try "rm -r foldername"

BUT BEWARE: there is no "undelete", so deleting subdirectories does occasionally lead to hair-pulling experiences!
 
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).
 
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...
 
and be very careful if you are root....

nothing like rm -rf * in /
 
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:
Code:
#!/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:
Code:
[xx@xx ~]$./cleanfloppy

First problem was this disk was corrupt so it wouldn't mount:
Code:
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)
Code:
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..
 
Just to be safe I have the following alias in my ~/.bashrc file
Code:
alias rm='rm -i'
Saved my bacon once or twice :D
 
Code:
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.
 
Top
Sign up to the MyBroadband newsletter
X