-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpositionalparameter
More file actions
93 lines (88 loc) · 1.46 KB
/
positionalparameter
File metadata and controls
93 lines (88 loc) · 1.46 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
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
#!/bin/bash
echo \$home is $HOME
echo \$PATH is $PATH
echo \$PS1 which is my prompt is $PS1
echo \$# is number of parms: $#
echo \$\$ is PID of this shell $$
echo I could create a file called /tmp/tmpfile_$$
echo \$0 is $0
echo \$1 is $1
echo \$2 is $2
echo \$3 is $3
echo \$4 is $4
echo "\$IFS is "
echo "START $IFS END"
echo '$@' is "$@"
echo '"$*"' is $*
echo '$*' is "$*"
IFS=':'
echo "\$IFS is "
echo "START $IFS END"
echo '$@' is $@
echo '"$@"' is "$@"
echo '$*' is $*
echo '"$*"' is "$*"
echo loop through '$@' no quotes
for i in $@
do
echo $i
done
echo loop through '"@"' with quotes
for i in "$@"
do
echo $i
done
echo loop through '$*' no quotes
for i in $*
do
echo $i
done
echo loop through '"$*"' with quotes
for i in "$*"
do
echo $i
done
unset IFS
set $(date)
echo "I reset parms to the date, so now the parms are "
for i in $*
do
echo $i
done
output:
--------
mandahasa48@instance-1:~/shell-scripts$ ./positionalparameter
$home is /home/mandahasa48
$PATH is /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
$PS1 which is my prompt is
$# is number of parms: 0
$$ is PID of this shell 978
I could create a file called /tmp/tmpfile_978
$0 is ./positionalparameter
$1 is
$2 is
$3 is
$4 is
$IFS is
START
END
$@ is
"$*" is
$* is
$IFS is
START : END
$@ is
"$@" is
$* is
"$*" is
loop through $@ no quotes
loop through "@" with quotes
loop through $* no quotes
loop through "$*" with quotes
I reset parms to the date, so now the parms are
Sat
Oct
1
15:40:54
UTC
2022