I have a directory which contains all the C programs. I have also compiled them at the creation time so as to check my code. There are a lot of programs nearly 100 of them. So I want a BASH script that would check whether the file ends with ".c". If it does then it does not do anything, which if it doesn't then it would remove them. Suppose one of my file name is "Hello.c" then I have named its binary during compile time as "Hello". So can anyone make this script for me?
There's probably a neater way, but you can do ls | grep -v '\.c$' | xargs rm |
|||||||||||||||||||
|
You can use the
If you do not want to use
Make sure in |
|||||||||
|
I always prefere
But be careful. Testing such commands is always a good idea. |
|||
|
Activate ksh extended wildcard patterns with the command
This is pretty dangerous as it deletes
This still deletes
Shorter, if your
|
|||
|