-
Notifications
You must be signed in to change notification settings - Fork 50
/
script00.sh
executable file
·46 lines (44 loc) · 1.07 KB
/
script00.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
#!/bin/bash
# MM2090 : Introduction to Scientific Computing
# Dept of MME, IIT Madras, Chennai 600036 INDIA
# G. Phanikumar gphani@iitm.ac.in
#
# This script illustrates special variables and the if loop
# Things to pay attention to:
# * Special variables $#, $$, $0, $1 etc.,
# * Use of the keyword "test" for if condition
# * Use of [ ] for if condition
# * Use of -gt for numeric comparison
# * Use of == for string comparison
# * Nested if loop
#
echo "Here is the output of script00.sh"
echo "Name of this script:"
echo $0
echo "Process ID of this script:"
echo $$
echo "Number of command line arguments:"
echo $#
echo "First command line argument:"
echo $1
echo "Second command line argument:"
echo $2
echo "Third command line argument:"
echo $3
if test $# -gt 2;
then
echo "[1] You gave more than two arguments";
if test $1 == $2;
then
echo "First two arguments are same"
fi
fi
if [ $# -gt 2 ]
then
echo "[2] You gave more than two arguments";
fi
#
# Homework:
# * Create a script that mimics the behavior of ls command
#
# ----- end of script00.sh -------------------------