June 2017
Beginner
502 pages
11h 26m
English
This forces redirection even if a noclobber option is set for the shell. Clobbering means the act of overwriting the content of a file, and this is something we have already seen with the redirection, but let's have a look at this example:
zarrelli:~$ echo "123" > override.txtzarrelli:~$ cat override.txt 123zarrelli:~$ echo "456" > override.txtzarrelli:~$ cat override.txt 456
Everything goes as expected. We redirected the output of the echo, and on the second run, we overwrote the content of the file. But let's now set the noclobber option for the shell:
zarrelli:~$ set -o noclobber
We will try to overwrite the content of the file:
zarrelli:~$ echo "789" > override.txtbash: override.txt: cannot overwrite existing ...
Read now
Unlock full access