![Jupyter Tutorial](/jupyter/images/jupyter-mini-logo.jpg)
- Jupyter Tutorial
- Jupyter - Home
- IPython
- IPython - Introduction
- IPython - Installation
- IPython - Getting Started
- Running & Editing Python Script
- IPython - History Command
- IPython - System Commands
- IPython - Command Line Options
- Dynamic Object Introspection
- IPython - IO Caching
- Setting IPython as Default Python Environment
- Importing Python Shell Code
- IPython - Embedding IPython
- IPython - Magic Commands
- Jupyter
- Project Jupyter - Overview
- Jupyter Notebook - Introduction
- Working With Jupyter Online
- Installation and Getting Started
- Jupyter Notebook - Dashboard
- Jupyter Notebook - User Interface
- Jupyter Notebook - Types of Cells
- Jupyter Notebook - Editing
- Jupyter Notebook - Markdown Cells
- Cell Magic Functions
- Jupyter Notebook - Plotting
- Converting Notebooks
- Jupyter Notebook - IPyWidgets
- QtConsole
- QtConsole - Getting Started
- QtConsole - Multiline Editing
- QtConsole - Inline Graphics
- QtConsole - Save to Html
- QtConsole - Multiple Consoles
- Connecting to Jupyter Notebook
- Using github and nbviewer
- JupyterLab
- JupyterLab - Overview
- Installation & Getting Started
- JupyterLab - Interface
- JupyterLab - Installing R Kernel
- Jupyter Resources
- Jupyter - Quick Guide
- Jupyter - Useful Resources
- Jupyter - Discussion
IPython - System Commands
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
![Exclamation Symbol (!) Command](/jupyter/images/exclamation_symbol_command.jpg)
The output of system command can also be assigned to a Python variable as shown below −
![Output of system command](/jupyter/images/output_system_command.jpg)
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 −
![System Command Calls](/jupyter/images/system_command_calls.jpg)
Here is another example to understand that prefixing Python variable with $ also achieves the same result.
![Prefixing Python Variable](/jupyter/images/prefixing_python_variable.jpg)
Advertisements