jrjohansson / scientific-python-lectures

Lectures on scientific computing with python, as IPython notebooks.
3.51k stars 1.8k forks source link

System commands are for UNIX machines, recommend supplemental file that describes how to make them work on Windows #33

Open cooknl opened 8 years ago

cooknl commented 8 years ago

UNIX system commands that show up in scientific-python-lectures and their Windows equivalents

PREFACE: The Windows "cmd" window is of limited utility. Powershell is a windows shell utility with a greater scripting language. To use Powershell from python as a magic, you can download and use powershellmagic

https://pypi.python.org/pypi/powershellmagic/0.1.0

Install as a Python package:

$ pip install powershellmagic

Use in IPython Notebooks

In [1]: %load_ext powershellmagic


UNIX ; WINDOWS


cat scripts/hello-world.py ; !type scripts/hello-world.py #for cmd window

or

%%powershell get-content scripts/hello-world.py


!head stockholm_td_adj.dat #There is no cmd window equivalent, !type will print the entire file ; %%powershell gc stockholm_td_adj.dat -TotalCount 3


!file random-matrix.npy ; !assoc random-matrix.npy #Not really equivalent to !file


!rm -f dprod.pyf ; %% powershell !rm -f dprod.pyf