If the statement in the input cell starts with the exclamation symbol (!), it is treated as a system command for underlying operating system. For example, !ls (for linux) and !dir (for windows) displays the contents of current directory
The output of system command can also be assigned to a Python variable as shown below −
The variable stores output without colors and splits at newline characters.
It is also possible to combine Python variables or expressions with system command calls. Variable in curly brackets {} can be embedded in command text. Observe the following example −
Here is another example to understand that prefixing Python variable with $ also achieves the same result.