In [ ]:
files = !ls -1
for file in files.grep('ipynb'):
!echo $file
There are also some interesting 'magics' for working on shells, for example if you want to run some bash-specific code:
In [ ]:
%%bash
echo "Running under $BASH"
echo "Only Bash could do this..."
echo {a,b,c}{d,e,f}
Or even perl:
In [ ]:
%%perl
use DateTime;
print "The first of next month: ";
print DateTime->today()->add(months => 1)->set(day => 1)->ymd;
The basic capabilities of
makes IPython Notebook great for quickly documenting "devops" processes.
For example, anything you can run via ssh you can quickly demonstrate, like finding the top recent account numbers referenced in one of our system logs:
In [11]:
!ssh ho "sudo head -2000 /var/log/mediatemple.log | awk '{print \$29}' | grep '[0-9]' | sort | uniq -c | sort -rn | head -10"
Even in a more analytics space than 'runbooks', that particular capability is useful.
Or, showing off a fabric task:
In [ ]:
!fab share:'Command Line Demo.ipynb'
In [ ]: