-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget_files_for_Makefile.bash
More file actions
executable file
·64 lines (51 loc) · 1.14 KB
/
get_files_for_Makefile.bash
File metadata and controls
executable file
·64 lines (51 loc) · 1.14 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# Bold High Intensity COLORS
BIBlack='\033[1;90m' # Black
BIRed='\033[1;91m' # Red
BIGreen='\033[1;92m' # Green
BIYellow='\033[1;93m' # Yellow
BIBlue='\033[1;94m' # Blue
BIPurple='\033[1;95m' # Purple
BICyan='\033[1;96m' # Cyan
BIWhite='\033[1;97m' # White
function print_if_it_is_c_file {
file=$1
extension=${file: -2}
if [ "$extension" == ".c" ]
then
echo "$file \\"
fi
}
function get_files {
output=`ls ./$1`
for file in $output
do
if [ -d "./$1/$file" ]
then
get_files "$1/$file"
elif [ -f "./$1/$file" ]
then
print_if_it_is_c_file "./$1/$file"
fi
done
}
if [ $# != 1 ] || [ ! -d $1 ]
then
echo -e "${BIYellow}please enter a valid path name"
echo -e -n "${BICyan}PS: "
echo -e "${BICyan}\`${BIWhite}./get_files_for_Makefile.bash .${BICyan}\`"
exit
fi
path="$1"
cd $path
output=`ls`
for file in $output
do
if [ -d "./$1/$file" ]
then
get_files "$file"
elif [ -f "./$1/$file" ]
then
print_if_it_is_c_file "$1/$file"
fi
done