LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   Removing non-empty directory (https://www.linuxquestions.org/questions/linux-from-scratch-13/removing-non-empty-directory-342317/)

satimis 07-11-2005 10:24 PM

Removing non-empty directory
 
Hi folks,

I was trying to remove '/sources/glibc-build' and '/sources/glibc-2.3.4-20040701', both non-empty with following steps without success


1) on LFS after chroot
Code:

root:/# rmdir -p --ignore-fail-on-non-empty ./sources/glibc-build/
root:/# rmdir -p --ignore-fail-on-non-empty ./sources/glibc-2.3.4-20040701/
root:/# ls -a ./sources/ | grep glibc-build
glibc-build
root:/# ls -a ./sources/ | grep glibc-2.3.4-20040701
glibc-2.3.4-20040701
glibc-2.3.4-20040701.tar.bz2
root:/# rmdir -p --ignore-fail-on-non-empty ./sources/glibc-build
root:/# ls -a ./sources/ | grep glibc-build
glibc-build

root:/# rmdir -pv --ignore-fail-on-non-empty ./sources/glibc-build
rmdir: removing directory, ./sources/glibc-build
root:/# ls -a ./sources/ | grep glibc-build
glibc-build
root:/# rmdir -pv --ignore-fail-on-non-empty ./sources/glibc-2.3.4-20040701
rmdir: removing directory, ./sources/glibc-2.3.4-20040701
root:/# ls -a ./sources/ | grep glibc-2.3.4-20040701
glibc-2.3.4-20040701
glibc-2.3.4-20040701.tar.bz2

They are still there.

2) Login as 'su -' on FC3 host
Code:

[satimis@localhost ~]$ su -
Password:
[root@localhost ~]# rmdir -pv --ignore-fail-on-non-empty /mnt/lfs/sources/glibc-build
rmdir: removing directory, /mnt/lfs/sources/glibc-build
[root@localhost ~]# ls /mnt/lfs/sources/glibc-build/

still showing them there.


Finally starting Konqueror as root on Konsole, I can remove them on Konqueror.

Please advise what was the trick behind.

TIA

B.R.
satimis

masand 07-11-2005 10:35 PM

try

rm -rf <directory name path etc>

use this with caution do not end up deleting all files on ur root

regards

satimis 07-11-2005 11:43 PM

Hi masand,

Tks for your advice.

Quote:

rm -rf <directory name path etc>
Quote:

rm -rf /path/to/directory
Noted with thanks.

In my personal opinion it will be more safe to remove them on 'Konqueror'.

B.R.
satimis

masand 07-12-2005 03:40 AM

well u should know about some more options
so that we u work on remote systems u are not stuck anywhere

regards

amitshah.in 03-05-2009 01:19 AM

Quote:

Originally Posted by masand (Post 1742159)
try

rm -rf <directory name path etc>

use this with caution do not end up deleting all files on ur root

regards

Hi Masand,

Thanks for you post. I'm trying to remove not empty directory and your post has provide me good help.

zzypty 03-09-2009 04:58 AM

Removing non-empty directories
 
Hey,

The best way to remove a directory is
Quote:

$ rm -r <path_to_directory>/<name_of_directory>
For eg, if I have a directory in my /mnt/lfs directory called foobar, then the command will be
Quote:

rm -r /mnt/lfs/foobar
The -r option is for 'recursive'. The 'rm' command recursively removes all the files from the folder and then the folder itself.

Please be very careful when deleting files as root. Please ensure that the path to the directory is correct. A wrong path might delete some important files off your computer.


All times are GMT -5. The time now is 10:33 AM.