-
Notifications
You must be signed in to change notification settings - Fork 2
/
LinuxExercise10
54 lines (34 loc) · 1.44 KB
/
LinuxExercise10
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
--Create a variable named TEXT with the value "The number is "
#!/bin/bash
read $INPUT_STRING
echo "The number is $INPUT_STRING"
--Write a for loop that prints numbers 1-25 after printing the value of TEXT each time.
#!/bin/bash
for i in 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
do
echo "Looping the numbers $i"
done
--Run the same command, this time redirecting the output to a file named forloop.out.
forLoop.sh > forloop.out
--Write a sed command that creates a new output file from forloop.out where instead of saying "the number is ", it will now say "the number is not ". Name the file forloop2.out
sed '/\[The number is\]/a not' forloop.out
--Try running the following if statement to get familiar with it:
i=1
if(( $i==1 ))
then
echo "i is equal to 1"
elif(($i==2))
then
echo "i is equal to 2"
else
echo "i is neither 1 or 2"
fi
--Change the value of i to be something not 1 or 2 and check that the statement works again.
works when changing i=3 >.
--Create a variable of today's date named TODAY in the format of DD.MM.YYYY.
TODAY_DATE= date +"%d-%m-%y"
--Create another variable named GENDATE that has the command to generate and store the same date.
GENDATE= date +"%d-%m-%y" > gendate.out
--Create a file named output.log with today’s date as an extension using the variable you just created.
GENDATE= date +%d-%m-%y
LOGFILE= ~/Users/jeff/Documents/Github/wiley-sre-training/$USER.man.$TODAY.log