Distributed Networks Distributed Networks

Unix Shell Programming   «Prev 
Using embedded execution in a for loop
Inserting a carriage return into a command
You can insert a literal character into a UNIX command by using a sequence of two characters. The first character will always be control V.
Control V asks the shell to insert the next character you type literally into your command and not to interpret it as something special. To insert a literal carriage return into a command, type control V, then type a carriage return. This looks curious on your screen as you type.

Recall that the ssh client has an escape sequence feature. By typing a particular character, normally a tilde (~), immediately after a newline or carriage return, you can send special commands to ssh: terminate the connection, suspend the connection, and so forth. But sometimes the default escape character can cause a problem. Suppose you connect by ssh from host A to host B, then from host B to host C, and finally from host C to host D, making a chain of ssh connections.
(We represent the machines´┐Ż shell prompts as A$, B$, C$, and D$.)
A$ ssh B
B$ ssh C
C$ ssh D
While logged onto host D, you press the Return key, then ~ ^Z (tilde followed byControl-Z) to suspend the connection temporarily. Well, you have got three ssh connections active, so which one gets suspended? The first one does, and this escape sequence brings you back to the host A prompt. Well, what if you want to escape back to host B or C ?
There are two methods, one with forethought and one on the spur of the moment.