How to delete a* file with out deleting file name starting with a?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How to delete a* file with out deleting file name starting with a?
# 1  
Old 12-14-2012
How to delete a* file with out deleting file name starting with a?

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.
Smilie
Thanx.
# 2  
Old 12-14-2012
execute the below command, and make sure, it prints the directory which you want to remove.

Code:
find . -type d -name "a*"

then issue the below command to remove it.

Code:
 
find . -type d -name "a*" -exec rm -rf {}\;

# 3  
Old 12-14-2012
Code:
find . -type d -name "a\*"

# 4  
Old 12-14-2012
Hi, itkamaraj

I tired your querries. But it is giving error

It is showing : "find missing argument to '-exec' "
# 5  
Old 12-14-2012
how to delete a* folder with deleting starting a letter folders

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.


ThanksSmilie
How to delete a* file with out deleting file name starting with a?-deletepng
# 6  
Old 12-14-2012
Separate the {}<space>\;
# 7  
Old 12-14-2012
Tip: test with echo first:
Code:
find . -type d -name "a*" -exec echo rm -rf {} \;

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep a log file starting from a specific time to the end of file

I have a log file which have a date and time at the start of every line. I need to search the log file starting from a specific time to the end of file. For example: Starting point: July 29 2018 21:00:00 End point : end of file My concern is what if the pattern of `July 29 2018 21:00:00`... (3 Replies)
Discussion started by: erin00
3 Replies

2. UNIX for Dummies Questions & Answers

How to grep a line not starting with # from a file (there are two lines starting with # and normal)?

e.g. File name: File.txt cat File.txt Result: #INBOUND_QUEUE=FAQ1 INBOUND_QUEUE=FAQ2 I want to get the value for one which is not commented out. Thanks, (3 Replies)
Discussion started by: Tanu
3 Replies

3. Shell Programming and Scripting

Deleting rows starting with a character and word

Hi, I have multiple files of same format and I want to delete the lines starting with # and The from all of them I am using egrep -v '^(#|$)' for # but unable to do for both # and The Please guide Thanks (12 Replies)
Discussion started by: bioinfo
12 Replies

4. Shell Programming and Scripting

awk - writing matching pattern to a new file and deleting it from the current file

Hello , I have comma delimited file with over 20 fileds that i need to do some validations on. I have to check if certain fields are null and then write the line containing the null field into a new file and then delete the line from the current file. Can someone tell me how i could go... (2 Replies)
Discussion started by: goddevil
2 Replies

5. Shell Programming and Scripting

Deleting lines not starting with numbers with sed

Title says all :p Thanks for your help (4 Replies)
Discussion started by: drbiloukos
4 Replies

6. Solaris

Before I delete any file in Unix, How can I check no open file handle is pointing to that file?

I know how to check if any file has a unix process using a file by looking at 'lsof <fullpath/filename>' command. I think using lsof is very expensive. Also to make it accurate we need to inlcude fullpath of the file. Is there another command that can tell if a file has a truely active... (12 Replies)
Discussion started by: kchinnam
12 Replies

7. Shell Programming and Scripting

Delete a line in a file starting with - Perl one-liner

Hi I need a perl onliner to delete a line in a file starting with few words. Example file.txt ---------- my name is don I live in London I am woking as engineer I want to delete a line starting with 'I live in' using perl oneliner and in place edit with out temporary files Thanks... (2 Replies)
Discussion started by: ammu
2 Replies

8. UNIX for Dummies Questions & Answers

Deleting lines starting with spaces then non-numerals

I did a search but couldn't find a thread that seemed to answer this but my apologies if it has been answered before. I have some text files and I need to remove any line that does not start with a number (0-9). In actuality every line like this starts with a 'T' (or 't') but there are a... (5 Replies)
Discussion started by: skray
5 Replies

9. Shell Programming and Scripting

How to delete initial N bytes from the starting of the file using sed?

I want to delete initial N bytes of a file using sed. How can I do that? (3 Replies)
Discussion started by: jockey007
3 Replies

10. Programming

How to delete N bytes from the starting of the file from a C function???

Hi, I want to delete the initial few lines (or even bytes) from a file. I want to do this from a C function & this is in Linux platform. The truncate & ftruncate is allowing me to delete bytes from the end only. Any linux C function calls or ideas or any suggestions?? I'm in a dead... (2 Replies)
Discussion started by: jockey007
2 Replies
Login or Register to Ask a Question