-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean_cwd.sh
More file actions
executable file
·46 lines (37 loc) · 963 Bytes
/
clean_cwd.sh
File metadata and controls
executable file
·46 lines (37 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#/usr/bin/env bash
CWD=`pwd`
dry_run=true
if [ $# == 1 ]; then
if [ $1 == "-r" ] || [ $1 == "--remove" ]; then
dry_run=false
fi
if [ $1 == "-h" ] || [ $1 == "--help" ] || [ $1 == "help" ]; then
echo ""
echo "Utility to delete executable's from current working directory!"
echo ""
echo "Default action will be a Dry-run on a specific path!"
echo ""
echo "Use '-r' or '--remove' to remove the files"
echo ""
echo "Use '-h' or '--help' or 'help' to print these messages again! or scream for help from God! :)"
echo ""
exit 0
fi
fi
if [ $dry_run = true ]; then
echo ""
echo "Dry run - invoke with '-r' or '--remove' to remove the files"
echo ""
fi
echo "Going to clear Current Working Directory [$CWD]"
for f in $(find . -type f -executable -not -path '*/\.*');
do
file $f | grep --silent 'executable'
if [ $? == 0 ];
then
echo "Removing an Executable [$f]"
if [ $dry_run = false ]; then
rm $f;
fi
fi
done