In the 7th example, we have used the combination of the Vim and Shell commands.
In this example:
:w
is a Vim command which writes buffer contents to the file.
!
is also a Vim command and it’s used to execute the shell command.
%
is a Vim register that represents the current file. In this case, it will be output.txt.
So in a nutshell, we are using the tee command to redirect the output of the :w
command to the current file i.e. output.txt. In this case, the file is owned by the root user. Hence we have to use the combination of the sudo and tee commands.
For the 8th example, let’s understand the command behavior without the -i
option. First, let’s use the tee command without any arguments:
[tecmint@tecmint]$ tee
In this case, the command will read the input from the standard input and will display it on the standard output. At any time, we can use the ctrl+C
key combination to terminate the command execution. This happens because the default behavior of the SIGINT signal is to terminate the process.
However, the same key combination will not work if we disable the interrupts using the -i
option. In that case, we have to use the ctrl+D
key combination to stop the command execution:
[tecmint@tecmint]$ tee -i
This option plays an important role when we want to redirect the continuous stream without interruption.
Just like other examples, we can also use the file names with this option.
]]>