LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-01-2013, 12:31 PM   #1
OtagoHarbour
Member
 
Registered: Oct 2011
Posts: 332

Rep: Reputation: 3
"No such file or directory" when using wild card


I am using Ubuntu 11.10.

I try to delete a directory using

Code:
sudo rmdir Peter/test9
and get

Code:
rmdir: failed to remove `Peter/test9': Directory not empty
I try

Code:
sudo ls Peter/test9
and see a list of files. But when I try

Code:
sudo rm Peter/test9/*
or

Code:
sudo rm Peter/test9/*.*
I get

Code:
rm: cannot remove `Peter/test9/*': No such file or directory
Code:
rm: cannot remove `Peter/test9/*.*': No such file or directory
I thought wild cards were supposed to represent any file. Also is there a way to recursivley delete a directory. I tried rmdir with the -r and -R switch but neither worked.

Thanks,
Peter.
 
Old 01-01-2013, 12:37 PM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
rmdir command will delete only empty directory, and that's why you're getting error Directory not empty. But in order to remove non-empty directory or it's content, use -r option with rm as:
Code:
rm -r /path/to/dir
Also did you check path of directory which you're trying to remove, as:-
Code:
ls -la Peter/test9/*
OR, 
ls -la /Peter/test9/*
 
Old 01-01-2013, 12:51 PM   #3
OtagoHarbour
Member
 
Registered: Oct 2011
Posts: 332

Original Poster
Rep: Reputation: 3
Quote:
Originally Posted by shivaa View Post
rmdir command will delete only empty directory, and that's why you're getting error Directory not empty. But in order to remove non-empty directory or it's content, use -r option with rm as:
Code:
rm -r /path/to/dir
Also did you check path of directory which you're trying to remove, as:-
Code:
ls -la Peter/test9/*
OR, 
ls -la /Peter/test9/*
I tried

Code:
sudo rmdir -r Peter/test9
and got

Code:
rmdir: invalid option -- 'r'
Try `rmdir --help' for more information.

I tried

Code:
ls -la Peter/test9/*
and got

Code:
ls: cannot access Peter/test9/*: No such file or directory
Thanks,
Peter

Last edited by OtagoHarbour; 01-01-2013 at 12:58 PM.
 
Old 01-01-2013, 01:00 PM   #4
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Once try -R option with rm.
Also did you check
Code:
ls -la /Peter/test9/*
(There should be a forward slash i.e. "/" at the beginning of the path)
 
Old 01-01-2013, 01:03 PM   #5
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
Try
Code:
ls -al path/to/file/.*.
 
Old 01-01-2013, 01:09 PM   #6
OtagoHarbour
Member
 
Registered: Oct 2011
Posts: 332

Original Poster
Rep: Reputation: 3
Quote:
Originally Posted by shivaa View Post
Once try -R option with rm.
Also did you check
Code:
ls -la /Peter/test9/*
(There should be a forward slash i.e. "/" at the beginning of the path)
Code:
sudo rmdir -R Peter/test9
rmdir: invalid option -- 'R'
Code:
ls -la /Peter/test9/*
ls: cannot access /Peter/test9/*: No such file or directory
I didn't expect the second one to work snce it is the absolute path from the root.
 
Old 01-01-2013, 01:11 PM   #7
OtagoHarbour
Member
 
Registered: Oct 2011
Posts: 332

Original Poster
Rep: Reputation: 3
Quote:
Originally Posted by spiky0011 View Post
Try
Code:
ls -al path/to/file/.*.
Code:
sudo ls -al Peter/test9/.*.
ls: cannot access Peter/test9/.*.: No such file or directory
 
Old 01-01-2013, 01:18 PM   #8
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
Can you cd in test9 dir?? run pwd from there
 
Old 01-01-2013, 01:23 PM   #9
OtagoHarbour
Member
 
Registered: Oct 2011
Posts: 332

Original Poster
Rep: Reputation: 3
Quote:
Originally Posted by spiky0011 View Post
Can you cd in test9 dir?? run pwd from there
Code:
pwd
/var/www/Dracula/Peter/test9
 
Old 01-01-2013, 01:24 PM   #10
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Ok, you may be running it from your current dir.
Anyway, once check that does Peter and test9 directories exist or not:-
Code:
ls -ld Peter test9
Check content of Peter/test9, what's inside it:-
Code:
ls -la Peter/test9

Last edited by shivaa; 01-01-2013 at 01:25 PM.
 
Old 01-01-2013, 01:28 PM   #11
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
When you run ls -al what dir are you in
It looks like you are in /var/www/Dracula
 
Old 01-01-2013, 01:37 PM   #12
OtagoHarbour
Member
 
Registered: Oct 2011
Posts: 332

Original Poster
Rep: Reputation: 3
Quote:
Originally Posted by spiky0011 View Post
When you run ls -al what dir are you in
It looks like you are in /var/www/Dracula
Yes. That is correct.

Thanks,
Peter.
 
Old 01-01-2013, 01:41 PM   #13
OtagoHarbour
Member
 
Registered: Oct 2011
Posts: 332

Original Poster
Rep: Reputation: 3
Quote:
Originally Posted by shivaa View Post
Ok, you may be running it from your current dir.
Anyway, once check that does Peter and test9 directories exist or not:-
Code:
ls -ld Peter test9
Check content of Peter/test9, what's inside it:-
Code:
ls -la Peter/test9
Code:
sudo ls -ld Peter test9
ls: cannot access test9: No such file or directory
drwx------ 13 www-data www-data 4096 2013-01-01 13:16 Peter
Code:
sudo ls -la Peter/test9
total 23152
drwxr-xr-x  2 www-data www-data     4096 2013-01-01 12:15 .
drwx------ 13 www-data www-data     4096 2013-01-01 13:16 ..
-rw-r--r--  1 www-data www-data 11725082 2013-01-01 12:15 file1.cel
-rw-r--r--  1 www-data www-data 11971599 2013-01-01 12:15 file2.cel
 
Old 01-01-2013, 01:41 PM   #14
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
From Dracula, ls -l shows correct permissions
 
Old 01-01-2013, 01:55 PM   #15
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
I take it you are a member of www-data
 
  


Reply

Tags
rm, rmdir, wildcard



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] "ifconfig eth0 up" doesn't work, cause of "no such file or directory" Sebi94 Linux - Networking 6 08-21-2012 10:39 PM
unpredictable "delete" "move to trash" or "cut" file menu option dorianrenato Linux - General 3 11-28-2011 06:41 PM
[SOLVED] Errors executing shell script: "command not found" and "no such file or directory" eko000 Linux - Newbie 1 01-14-2011 07:54 AM
"bad interpreter : no such file or directory" when configure "flex" acer_peri Linux - Software 10 11-10-2010 01:19 AM
Error: "libdmx.so.1: cannot open shared object file: No such file or directory" ESC201 Linux - Software 4 11-01-2008 08:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration