-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.sh
240 lines (184 loc) · 4.13 KB
/
main.sh
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#function to create files
function createFiles() {
touch cs se ee ce
}
#function to add roll numbers according to the format {takes batch as argument}
function addRollNumbers() {
cd ..
cd $1
#in files: (cs se ee ce)
for i in ./*
do
# 130 roll nmbrs tk add
for j in {1..130}
do
if [ $j -lt 10 ]
then
echo $1-00$j-$i >> $i
#awk '{gsub(/\/|\./,"")}1'
else if [ $j -lt 100 ]
then
echo $1-0$j-$i >> $i
else
echo $1-$j-$i >> $i
fi
fi
done
done
}
#function to remove the first 130 lines and filter . and /
function removeLines() {
cd ..
cd $1
awk '{gsub(/\/|\./,"")}1' cs >> cs
sed -i '1,130d' cs
awk '{gsub(/\/|\./,"")}1' se >> se
sed -i '1,130d' se
awk '{gsub(/\/|\./,"")}1' ee >> ee
sed -i '1,130d' ee
awk '{gsub(/\/|\./,"")}1' ce >> ce
sed -i '1,130d' ce
}
#check if directory is present or not and create if it isnt
if [ -d rollNumbers ]
then
echo "Directory is present"
else
echo "Directory isnt present, creating one!"
mkdir rollNumbers
echo "done, creating subdirectories now"
#move inro the directory and create subdirectories
cd rollNumbers
mkdir 19b 20b 21b 21sp 21f
#in every batch-subdirectory create major-files
echo "done, creating files in eac subdirectory"
cd 19b
createFiles
cd ../20b
createFiles
cd ../21b
createFiles
cd ../21sp
createFiles
cd ../21f
createFiles
echo "done creating files"
fi
echo
echo "Adding roll numbers"
addRollNumbers 19b
addRollNumbers 20b
addRollNumbers 21b
addRollNumbers 21sp
addRollNumbers 21f
echo "done adding roll numbers"
echo
echo "Removing first 130 lines with . and /"
removeLines 19b
removeLines 20b
removeLines 21b
removeLines 21sp
removeLines 21f
echo "done removing lines"
# #Function to create files
# createFiles() {
# touch cs se ee ce
# }
# #Function to add roll numbers to the files
# addRollNumbers() {
# local batch="$1"
# for i in cs se ee ce; do
# for j in $(seq -w 1 130); do
# echo "$batch-$j-$i" >> "$i"
# done
# done
# }
# #Function to remove the first 130 lines and filter . and /
# removeLines() {
# for i in cs se ee ce; do
# awk '{gsub(/\/|\./,"")}1' "$i" > "$i.tmp" && tail -n +131 "$i.tmp" > "$i" && rm "$i.tmp"
# done
# }
# #Create rollNumbers directory and subdirectories if not present
# if [ ! -d rollNumbers ]; then
# echo "Directory is not present, creating one!"
# mkdir rollNumbers
# echo "Done, creating subdirectories now"
# cd rollNumbers
# for subdir in 19b 20b 21b 21sp 21f; do
# mkdir "$subdir"
# done
# echo "Done, creating files in each subdirectory"
# for subdir in 19b 20b 21b 21sp 21f; do
# cd "$subdir"
# createFiles
# cd ..
# done
# echo "Done creating files"
# fi
# echo "Adding roll numbers"
# cd rollNumbers
# for subdir in 19b 20b 21b 21sp 21f; do
# cd "$subdir"
# addRollNumbers "$subdir"
# cd ..
# done
# echo "Done adding roll numbers"
# echo "Removing first 130 lines with . and /"
# for subdir in 19b 20b 21b 21sp 21f; do
# cd "$subdir"
# removeLines
# cd ..
# done
# echo "Done removing lines"
# #Function to create files
# createFiles() {
# touch cs se ee ce
# }
# #Function to add roll numbers to the files
# addRollNumbers() {
# local batch="$1"
# for i in cs se ee ce; do
# for j in $(seq -w 1 130); do
# echo "$batch-$j-$i" >> "$i"
# done
# done
# }
# #Function to remove the first 130 lines and filter . and /
# removeLines() {
# for i in cs se ee ce; do
# awk '{gsub(/\/|\./,"")}1' "$i" > "$i.tmp" && tail -n +131 "$i.tmp" > "$i" && rm "$i.tmp"
# done
# }
# #Create rollNumbers directory and subdirectories if not present
# if [ ! -d rollNumbers ]; then
# echo "Directory is not present, creating one!"
# mkdir rollNumbers
# echo "Done, creating subdirectories now"
# cd rollNumbers
# for subdir in 19b 20b 21b 21sp 21f; do
# mkdir "$subdir"
# done
# echo "Done, creating files in each subdirectory"
# for subdir in 19b 20b 21b 21sp 21f; do
# cd "$subdir"
# createFiles
# cd ..
# done
# echo "Done creating files"
# fi
# echo "Adding roll numbers"
# cd rollNumbers
# for subdir in 19b 20b 21b 21sp 21f; do
# cd "$subdir"
# addRollNumbers "$subdir"
# cd ..
# done
# echo "Done adding roll numbers"
# echo "Removing first 130 lines with . and /"
# for subdir in 19b 20b 21b 21sp 21f; do
# cd "$subdir"
# removeLines
# cd ..
# done
# echo "Done removing lines"