Hi,
I have a query:
I have a bunch of files starting letter with 'a'
(example: abhi,all,anand,animal,a1.txt,allow.java,a*)
here i want to delete/remove only a* folder but not other files and folders. and a* folder is present in so many other folders.
what is unix command to delete above query.
Thanx.
execute the below command, and make sure, it prints the directory which you want to remove.
find . -type d -name "a*"
then issue the below command to remove it.
find . -type d -name "a*" -exec rm -rf {}\;
find . -type d -name "a\*"
Hi, itkamaraj
I tired your querries. But it is giving error
It is showing : "find missing argument to '-exec' "
Hi,
Please find the below image.
How to delete containing folder name as a*, but i don't want delete folder nams which starting letter is a.
Thanks:)
Tip: test with echo first:
find . -type d -name "a*" -exec echo rm -rf {} \;
The asterisk would still need to be escaped if the directories that are named a*
are to be removed..
You are right, should be "a\*" in this case!
(I gave an unwanted demonstration how useful an echo test can be...)
1 Like
bsrwt
10
find . -type f -name "a\*" -exec rm -rf {} \;