LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   "No such file or directory" when using wild card (https://www.linuxquestions.org/questions/linux-newbie-8/no-such-file-or-directory-when-using-wild-card-4175443697/)

OtagoHarbour 01-01-2013 12:31 PM

"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.

shivaa 01-01-2013 12:37 PM

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/*


OtagoHarbour 01-01-2013 12:51 PM

Quote:

Originally Posted by shivaa (Post 4860743)
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

shivaa 01-01-2013 01:00 PM

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)

spiky0011 01-01-2013 01:03 PM

Try
Code:

ls -al path/to/file/.*.

OtagoHarbour 01-01-2013 01:09 PM

Quote:

Originally Posted by shivaa (Post 4860759)
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.

OtagoHarbour 01-01-2013 01:11 PM

Quote:

Originally Posted by spiky0011 (Post 4860760)
Try
Code:

ls -al path/to/file/.*.

Code:

sudo ls -al Peter/test9/.*.
ls: cannot access Peter/test9/.*.: No such file or directory


spiky0011 01-01-2013 01:18 PM

Can you cd in test9 dir?? run pwd from there

OtagoHarbour 01-01-2013 01:23 PM

Quote:

Originally Posted by spiky0011 (Post 4860767)
Can you cd in test9 dir?? run pwd from there

Code:

pwd
/var/www/Dracula/Peter/test9


shivaa 01-01-2013 01:24 PM

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

spiky0011 01-01-2013 01:28 PM

When you run ls -al what dir are you in
It looks like you are in /var/www/Dracula

OtagoHarbour 01-01-2013 01:37 PM

Quote:

Originally Posted by spiky0011 (Post 4860772)
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.

OtagoHarbour 01-01-2013 01:41 PM

Quote:

Originally Posted by shivaa (Post 4860770)
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


spiky0011 01-01-2013 01:41 PM

From Dracula, ls -l shows correct permissions

spiky0011 01-01-2013 01:55 PM

I take it you are a member of www-data


All times are GMT -5. The time now is 09:47 PM.