June 2017
Beginner
502 pages
11h 26m
English
The colon does actually nothing except expanding arguments and performing redirection. It can be handy in cycles and tests to actually do nothing if a condition is met. It is also interesting to see how it can be used to evaluate a series of variables using the parameter substitution:
#!/bin/bashx=32y=5: ${x?} ${y?} ${z?}And now let's execute it:zarrelli:~$ ./test-variable.sh./test-variable.sh: line 5: z: parameter null or not set
Here is a bite on redirection:
zarrelli:~$ echo "012345679" > test.colon.2zarrelli:~$ ls -lah test.colon.2-rw-r--r-- 1 zarrelli zarrelli 10 Feb 19 14:18 test.colon.2zarrelli:~$ : > test.colon.2zarrelli:~$ ls -lah test.colon.2-rw-r--r-- 1 zarrelli zarrelli 0 Feb 19 14:18 test.colon.2
So, what ...
Read now
Unlock full access