c-first-steps

a C playground
Index Commits Files Refs README
commit c2a44f60fd18618114ec9f94591e095d381aae15
parent 4cd18784167509d1401905ae2ceb616788553c29
Author: Martin J. Klöckner <martin.cachari@gmail.com>
Date:   Wed, 16 Dec 2020 01:33:34 -0300

Added a simple script to keep repo clean of 'a.out' garbage;

Diffstat:
M95.11/clean.sh | 30++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/95.11/clean.sh b/95.11/clean.sh
@@ -1,27 +1,25 @@
-#1/bin/bash
+#!/bin/bash
 
 # Removes every a.out from every subfolder where the 
 # sript is executed;
 
 # Set the filename;
-file="a.out"
+file='a.out'
 
-# Check the file if exist or not;
-if [ -f ./**/"$file" ] 
+# The path where 'file' is gonna be looked for;
+subfolders=./**/$file
+currentdir=./$file
 
-# if exists in any folder then removes it;
-    then
-        rm -v ./**/"$file" 
-        echo "everithing cleaned succesfully "
-
-# also removes it if existes in the current directory;
-elif [ -f "$file" ]
-    then
-        rm -v "$file"
-        echo "everithing cleaned succesfully "
+# First checks  if the file exist in the current directory
+# or in any sub-folder, if exist removes it from everywhere;
+if [ -e $currentdir ] || [ -e $subfolders ];
+then
+        rm -v -f ./**/"$file" 
+        rm -v -f "$file"
+        echo "everithing cleaned succesfully"
 
 # if doesn't exist then does nothing;
 else
-        echo "everything seems clean "
-        echo "there is nothing to do "
+        echo "everything seems clean"
+        echo "there is nothing to do"
 fi