Prefixed Linux commands with ! so they can be executed within IPython Notebook.

This commit is contained in:
Donne Martin 2015-03-13 07:59:28 -04:00
parent 23d3866b8e
commit a9ea93b872

View File

@ -1,7 +1,7 @@
{ {
"metadata": { "metadata": {
"name": "", "name": "",
"signature": "sha256:aa55f3f5af827289e0e805beeac7bc3bafcc5a85403717370daaa909851ea0c4" "signature": "sha256:7cdf1e36fef9e69cd9007eb0c5945e4d6440b31108bfddd6f19aa71d0d1a06ab"
}, },
"nbformat": 3, "nbformat": 3,
"nbformat_minor": 0, "nbformat_minor": 0,
@ -42,7 +42,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"df -h" "!df -h"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -59,7 +59,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"du -h ./" "!du -h ./"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -76,7 +76,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"du -sh ../" "!du -sh ../"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -93,7 +93,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"du -csh ./" "!du -csh ./"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -117,7 +117,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"wc -l < file.txt" "!wc -l < file.txt"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -134,7 +134,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"grep -c \".\" file.txt" "!grep -c \".\" file.txt"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -151,7 +151,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"split -l 20 file.txt new" "!split -l 20 file.txt new"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -168,7 +168,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"split -l 802 -a 1 file.csv dir/part-user-csv.tbl-" "!split -l 802 -a 1 file.csv dir/part-user-csv.tbl-"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -192,7 +192,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"ls -1 | grep .txt | wc -l" "!ls -1 | grep .txt | wc -l"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -209,7 +209,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"cat * | grep -c \"foo\" folder/part*" "!cat * | grep -c \"foo\" folder/part*"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -226,7 +226,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"sed -i '/Important Lines: /d\u2019 original_file" "!sed -i '/Important Lines: /d\u2019 original_file"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -244,31 +244,31 @@
"collapsed": false, "collapsed": false,
"input": [ "input": [
"# Compress zip\n", "# Compress zip\n",
"zip -r archive_name.zip folder_to_compress\n", "!zip -r archive_name.zip folder_to_compress\n",
"\n", "\n",
"# Compress zip without invisible Mac resources\n", "# Compress zip without invisible Mac resources\n",
"zip -r -X archive_name.zip folder_to_compress\n", "!zip -r -X archive_name.zip folder_to_compress\n",
"\n", "\n",
"# Extract zip\n", "# Extract zip\n",
"unzip archive_name.zip\n", "!unzip archive_name.zip\n",
"\n", "\n",
"# Compress TAR.GZ\n", "# Compress TAR.GZ\n",
"tar -zcvf archive_name.tar.gz folder_to_compress\n", "!tar -zcvf archive_name.tar.gz folder_to_compress\n",
"\n", "\n",
"# Extract TAR.GZ\n", "# Extract TAR.GZ\n",
"tar -zxvf archive_name.tar.gz\n", "!tar -zxvf archive_name.tar.gz\n",
"\n", "\n",
"# Compress TAR.BZ2\n", "# Compress TAR.BZ2\n",
"tar -jcvf archive_name.tar.bz2 folder_to_compress\n", "!tar -jcvf archive_name.tar.bz2 folder_to_compress\n",
"\n", "\n",
"# Extract TAR.BZ2\n", "# Extract TAR.BZ2\n",
"tar -jxvf archive_name.tar.bz2\n", "!tar -jxvf archive_name.tar.bz2\n",
"\n", "\n",
"# Extract GZ\n", "# Extract GZ\n",
"gunzip archivename.gz\n", "!gunzip archivename.gz\n",
"\n", "\n",
"# Uncompress all tar.gz in current directory to another directory\n", "# Uncompress all tar.gz in current directory to another directory\n",
"for i in *.tar.gz; do echo working on $i; tar xvzf $i -C directory/ ; done" "!for i in *.tar.gz; do echo working on $i; tar xvzf $i -C directory/ ; done"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -286,28 +286,28 @@
"collapsed": false, "collapsed": false,
"input": [ "input": [
"# Display the curl output:\n", "# Display the curl output:\n",
"curl donnemartin.com\n", "!curl donnemartin.com\n",
"\n", "\n",
"# Download the curl output to a file:\n", "# Download the curl output to a file:\n",
"curl donnemartin.com > donnemartin.html\n", "!curl donnemartin.com > donnemartin.html\n",
"\n", "\n",
"# Download the curl output to a file -o\n", "# Download the curl output to a file -o\n",
"curl -o image.png http://i1.wp.com/donnemartin.com/wp-content/uploads/2015/02/splunk_cover.png\n", "!curl -o image.png http://i1.wp.com/donnemartin.com/wp-content/uploads/2015/02/splunk_cover.png\n",
"\n", "\n",
"# Download the curl output to a file, keeping the original file name -O\n", "# Download the curl output to a file, keeping the original file name -O\n",
"curl -O http://i1.wp.com/donnemartin.com/wp-content/uploads/2015/02/splunk_cover.png\n", "!curl -O http://i1.wp.com/donnemartin.com/wp-content/uploads/2015/02/splunk_cover.png\n",
" \n", " \n",
"# Download multiple files, attempting to reuse the same connection\n", "# Download multiple files, attempting to reuse the same connection\n",
"curl -O url1 -O url2\n", "!curl -O url1 -O url2\n",
"\n", "\n",
"# Follow redirects -L\n", "# Follow redirects -L\n",
"curl -L url\n", "!curl -L url\n",
"\n", "\n",
"# Resume a previous download -C -\n", "# Resume a previous download -C -\n",
"curl -C - -O url\n", "!curl -C - -O url\n",
"\n", "\n",
"# Authenticate -u\n", "# Authenticate -u\n",
"curl -u username:password url" "!curl -u username:password url"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -325,19 +325,19 @@
"collapsed": false, "collapsed": false,
"input": [ "input": [
"# Display sorted info about processes\n", "# Display sorted info about processes\n",
"top\n", "!top\n",
"\n", "\n",
"# Display all running processes\n", "# Display all running processes\n",
"ps aux | less\n", "!ps aux | less\n",
"\n", "\n",
"# Display all matching running processes with full formatting\n", "# Display all matching running processes with full formatting\n",
"ps -ef | grep python\n", "!ps -ef | grep python\n",
"\n", "\n",
"# See processes run by user dmartin\n", "# See processes run by user dmartin\n",
"ps -u dmartin\n", "!ps -u dmartin\n",
"\n", "\n",
"# Display running processes as a tree\n", "# Display running processes as a tree\n",
"pstree" "!pstree"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -381,7 +381,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"source ~/.bash_profile" "!source ~/.bash_profile"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -443,7 +443,7 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"vimtutor" "!vimtutor"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
@ -460,8 +460,9 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"cd ~\n", "!cd ~\n",
"vim .vimrc\n", "!vim .vimrc\n",
"# Add the following to ~/.vimrc\n",
"syntax on\n", "syntax on\n",
":wq" ":wq"
], ],