-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemo
More file actions
executable file
·194 lines (160 loc) · 4.24 KB
/
Copy pathmemo
File metadata and controls
executable file
·194 lines (160 loc) · 4.24 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
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
#!/usr/bin/env bash
if [[ $# -eq 1 ]] || [[ $# -eq 10 ]]
then
echo "1 ou 10"
fi
if [[ $# -eq 1 ]] && [[ $# -eq 10 ]]
then
echo "1 et 10"
fi
if [[ -f "/home/dionisos/.bashrc" ]]
then
echo "/home/dionisos/.bashrc is a file" # sortie
else
echo "/home/dionisos/.bashrc is not a file"
fi
if [[ -f "/home/dionisos/" ]]
then
echo "/home/dionisos/ is a file"
else
echo "/home/dionisos/ is not a file" # sortie
fi
if [[ -f "/home/dionisos/" ]]
then
echo "/home/dionisos/ is a directory"
else
echo "/home/dionisos/ is not a directory"
fi
if [[ -e /home/dionisos/ ]]
then
echo "-e /home/dionisos"
fi
if [[ -e /home/dionisos/.bashrc ]]
then
echo "-e /home/dionisos/.bashrc"
fi
# echo * # affiche tout les fichiers du dossiers
for file in "file1" "file2" "file3"
do
echo "$file"
done
variable="plop"
echo $variable # sortie = "plop"
# read input
# echo $input
if [ $# -ne 1 ]
then
echo "Nombre d’argument différent de 1"
fi
if [ ! $# -ne 1 ]
then
echo "Nombre d’argument égal à 1"
echo "arg1 → $1"
elif [ $# -le 2 ]
then
echo "Nombre d’argument inférieur ou égal à 2"
fi
function funct1()
{
echo "funct1"
}
funct1
file="~/plop.ext/"
extension=${file##*.}
without_extension=${file%.*}
file_name=$(basename "$file")
substring=${file:2:5} #commence au 3ème caractère et finit 5 caractères plus loin
echo "\$file=="$file
echo "\$extension=="$extension
echo "\$without_extension=="$without_extension
echo "\$file_name=="$file_name
echo "$substring=="$substring
#export/alias/source voir ~/script/boot_config
case "plop" in
pl) echo "pl";;
lop) echo "plop";;
*op) echo "*op";;
*) echo "nothing";;
esac
the_date=$(date)
echo $the_date
echo \"
# while read line
# do
# echo $line
# done
tab=("a" "b" "c")
echo ${tab[@]}
echo ${tab[1]}
s=2
a=10
while [[ a -ge 0 ]]
do
echo $a
a=$((a - s))
done
# Conditional expressions are used by the [[ compound command and
# the test and [ builtin commands to test file attributes and per‐
# form string and arithmetic comparisons. Expressions are formed
# from the following unary or binary primaries. If any file argu‐
# ment to one of the primaries is of the form /dev/fd/n, then file
# descriptor n is checked. If the file argument to one of the
# primaries is one of /dev/stdin, /dev/stdout, or /dev/stderr,
# file descriptor 0, 1, or 2, respectively, is checked.
# Unless otherwise specified, primaries that operate on files fol‐
# low symbolic links and operate on the target of the link, rather
# than the link itself.
# When used with [[, the < and > operators sort lexicographically
# using the current locale. The test command sorts using ASCII
# ordering.
# -a file
# True if file exists.
# -d file
# True if file exists and is a directory.
# -f file
# True if file exists and is a regular file.
# -r file
# True if file exists and is readable.
# -s file
# True if file exists and has a size greater than zero.
# -w file
# True if file exists and is writable.
# -x file
# True if file exists and is executable.
# -L file
# True if file exists and is a symbolic link.
# file1 -ef file2
# True if file1 and file2 refer to the same device and
# inode numbers.
# file1 -nt file2
# True if file1 is newer (according to modification date)
# than file2, or if file1 exists and file2 does not.
# file1 -ot file2
# True if file1 is older than file2, or if file2 exists and
# file1 does not.
# -z string
# True if the length of string is zero.
# string
# stringTrue if the length of string is non-zero.
# string1 == string2
# string1 = string2
# True if the strings are equal. = should be used with the
# test command for POSIX conformance. When used with the
# [[ command, this performs pattern matching as described
# above (Compound Commands).
# string1 != string2
# True if the strings are not equal.
# string1 < string2
# True if string1 sorts before string2 lexicographically.
# string1 > string2
# True if string1 sorts after string2 lexicographically.
# arg1 OP arg2
# OP is one of -eq, -ne, -lt, -le, -gt, or -ge. These
# arithmetic binary operators return true if arg1 is equal
# to, not equal to, less than, less than or equal to,
# greater than, or greater than or equal to arg2, respec‐
# tively. Arg1 and arg2 may be positive or negative inte‐
# gers.
file="/home/dionisos/plop.ext"
length=${#parameter}
echo $length