You are not logged in.
Pages: 1
Hi
I tried using
rm ./directory
to delete some directory and it won't let me! It says it can't delete directories. This sounds weird so I thought I would ask if this is true. The directory has 3 files in it and it is not critical. I am logged in as root
Advice?
Offline
delete it recursively with
rm -r ./directory
"Unix is basically a simple operating system, but you have to be a genius to understand the simplicity." (Dennis Ritchie)
Offline
I could give you the answer...but try this first:
man rm
If you still can't figure it out, post back.
Offline
see also ``rmdir"
Offline
Thanks for the replies. rmdir worked as long as I deleted all the files in the directory first. Is there a way to just force it to all be deleted? Maybe rmdir -f? lol
Also, can you string together files to be deleted?
ie. rm /a /b /c
would delete files a, b and c?
Offline
rm -rf directory
Offline
Thanks for the replies. rmdir worked as long as I deleted all the files in the directory first. Is there a way to just force it to all be deleted? Maybe rmdir -f? lol
The best thing to do is to either use "man [command]" or "[command] --help" to learn about syntax and available options and switches. Having said that, I never use rmdir, but "rm -r" deletes the directory and everything inside it.
Also, can you string together files to be deleted?
ie. rm /a /b /c
would delete files a, b and c?
Yes.
Offline
ie. rm /a /b /c
would delete files a, b and c?
Yup, try it and see!
If you're afraid of experimenting with rm, use "rm -i" and it will ask you "are you sure" for each file it thinks you asked it to delete.
Offline
a good thing to do is also put
alias rm='rm -i'
in your ~/.bashrc
It might be a pain in the ass after a while, but one day it might just save your ass
Offline
Thanks, I will!
Offline
and if you want to delete multiple files, remember wildcards
e.g.
rm /some/directory/*
or
rm /picture/directory/PIC????
Offline
rm --help
tells you
-r, -R, --recursive remove directories and their contents recursively
but of course, it's not necessarily understandable by everyone what "recursive" means. It may well be a scary thing. But then you must not have been using Linux for long, in which case I wish you luck and joy in using Arch.
Jokes aside, add the -r option to any alias for rm. Or for a fun way of life
# nano /usr/bin/delete
then paste in
#!/bin/bash
# /usr/bin/delete: Simple AND stupid trasher
date=$(date +%d-%m-%y)
if [ ! -d ${HOME}/.trash/$date ]; then
mkdir -p ${HOME}/.trash/$date
fi
for i in $@; do
mv $i ${HOME}/.trash/$date
done
}
and then
# chmod 755 /usr/bin/delete
and you may
delete file directory whatever whenever
and the files will be in ~/.trash waiting for you to
for i in `ls -a1 --color=never ${HOME}/.trash`; do rm -rIv $i; done
one fine day Except if both a file and directory have the same names it will not work. And so, it's stupid. But i loike.
Last edited by schivmeister (2008-02-08 01:19:54)
I need real, proper pen and paper for this.
Offline
a good thing to do is also put
alias rm='rm -i'
in your ~/.bashrc
It might be a pain in the ass after a while, but one day it might just save your ass
this is a really bad idea. sure, it will save your ass on your system, but what if you are ssh'd into a system and for whatever reason that alias isn't set. you will be expecting it and screw yourself over.
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline
Just a heads up here.
If you didn't know how to delete a directory... there is a small chance that ArchLinux is not the right distro for you to learn linux on. You could really hurt data/etc. I don't want to stop you from using it if you really want to, I'm just sayin' it so I can say toldyaso later.
Offline
Pages: 1