The Unix and Linux overruling noclobber means you can overwrite an existing file while noclobber is set by using ‘>|’ sign.
Sample syntax of :
# command >|<filename>
# echo Welcome to JavaTpoint. >| newfile.txt
After run the command see your terminal, with greater than ‘>’ sign. Bash doesn’t allow to overwrite the file ‘newfile.txt’. But with ‘>|’ sign file is overwrite.
The Linux >>append command
Append ‘>>’ sign doesn’t let the file content to be overwrite and hence, displays new as well as old file content.
Sample syntax of append command :
# command >> <filename>
Like example of append :
# echo You all are welcome here. >> newfile.txt
See your terminal after run the command, file ‘newfile.txt’ is not overwrite with append command. New content is display with the old one.
Linux Error Redirection
‘2>’ redirects the error of an output.It helps us you to keep our display less messy by redirecting error messages.
Like example of erro redirection :
# zcho hyii 2> /dev/null
After run command see your command, by using command “zcho hyii 2> /dev/null” (here echo command is wrong). We didn’t get any error message.
But when we use command “zcho hyii” error message is display in the terminal.
2> means redirects the error message in the mentioned directory keeping your terminal error message free.
This Linux command helps in redirecting the stdout and stderr in the same file.
Like example of the command :
# newfile.txt > abc.txt and error.txt 2>&1
After run the command see your terminal, ‘abc.txt and error.txt’ is directing to the same file ‘newfile.txt’.
Here: Order of redirections is really important.
If you’ll write:
# ls > dirlist 2>&1
stdout and stderr both will be direct to the file dirlist.
But if you’ll write
# ls 2>&1 > dirlist
then, only stdout will be redirect to dirlist. Before the stdout is redirect to dirlist, stderr has made a copy of stdout.
If you understand this article, then you can practice it more and more. If you practice more and more than you can got this information with expert person.