-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathAutomated_Script_to_Create_File.sh
72 lines (54 loc) · 1.6 KB
/
Automated_Script_to_Create_File.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
# Developer: Pankaj Kumar
# command to run file is bash -f hello.sh
#!/bin/bash
echo "Enter first character of platform only"
echo "Like L for Leetcode, A for AtCoder and C for Codeforces"
read platform_name
if [ "$platform_name" == "l" ] || [ "$platform_name" == "L" ]
# here space between bracket, operator and operand is necessary
# otherwise it will give error
then
platform_name="Leetcode"
elif [ "$platform_name" == "a" ] || [ "$platform_name" == "A" ]
then
platform_name="AtCoder"
elif [ "$platform_name" == "c" ] || [ "$platform_name" == "C" ]
then
platform_name="Codeforces"
else
echo "You want to mention platform name, Y/N ? "
read answer
if [ "$answer" == "Y" ] || [ "$answer" == "y" ]
then
echo "Enter platform name: "
read platform_name
else
echo "deafult platform name is 'unknown' "
platform_name="unkown"
fi
fi
# -----------------------------------------------------------------------------------
# assign read file
if [ "$platform_name" == "Leetcode" ]
then
read_file="LeetCode.cpp"
elif [ "$platform_name" == "AtCoder" ]
then
read_file="../../Atcoder.cpp"
else
read_file="Cf.cpp"
fi
# -----------------------------------------------------------------------------------
# to create file with given name
echo "how many file you want to create"
read no_of_file
for i in $(seq 1 $no_of_file)
do
filename="$platform_name"_"$i.cpp"
touch $filename
command_to_run=`cat $read_file`
# command which you want to run
echo "$command_to_run" > $filename
# file with correct file name is created
done
echo "done"