Article 6D9KT bash script to safely and recursively delete files with no extension

bash script to safely and recursively delete files with no extension

by
amikoyan
from LinuxQuestions.org on (#6D9KT)
I am slowly working my way through KN King's 'C Programming - a modern approach'. I use geany as an IDE, which creates an 'executable' file with no extension when I compile each source file e.g. heapsort.c would create a file called heapsort. I create many such files and it is a pain to track them down and remove them. I wish to keep the source files.
I have the following directory structure
Code:/home/mik/C/knking/ch_[1-9]So, seems like a job for a bash script. So, I have created clean.sh:

Code:#!/bin/sh
find . -type f ! -name "*.*" -deletewhich I have placed in the /home/mik/C/knking directory. The idea is it recursively deletes files with no extension in the knking directory and the chapter directories below... and nowhere else.

I am scared to run it 'as is' - I have visions of deleting crucial system files.

I have tested it without the -delete and it finds the correct files.

My questions are: is it safe to use from the knking directory? Is there a better/safer solution?
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments