|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377 |
- {
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# 2.1. Learning the basics of the Unix shell"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 1,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "~/git/cookbook-2nd/chapter02_best_practices\n"
- ]
- }
- ],
- "source": [
- "pwd"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "00_intro.md 03_git.md 07_high_quality.md\n",
- "01_shell.md 04_git_advanced.md 08_test.md\n",
- "02_py3 05_workflows.md 09_debugging.md\n",
- "02_py3.md 06_tips.md images\n"
- ]
- }
- ],
- "source": [
- "ls"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "total 100\n",
- "-rw-rw-r-- 1 owner 769 Dec 12 10:23 00_intro.md\n",
- "-rw-rw-r-- 1 owner 2473 Dec 12 14:21 01_shell.md\n",
- "...\n",
- "-rw-rw-r-- 1 owner 9390 Dec 12 11:46 08_test.md\n",
- "-rw-rw-r-- 1 owner 5032 Dec 12 10:23 09_debugging.md\n",
- "drwxrwxr-x 2 owner 4096 Aug 1 16:49 images\n"
- ]
- }
- ],
- "source": [
- "ls -l"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {},
- "outputs": [],
- "source": [
- "cd images"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "~/git/cookbook-2nd/chapter02_best_practices/images"
- ]
- },
- "execution_count": 5,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "pwd"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "folder.png github_new.png\n"
- ]
- }
- ],
- "source": [
- "ls"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 7,
- "metadata": {},
- "outputs": [],
- "source": [
- "cd .."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 8,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "~/git/cookbook-2nd/chapter02_best_practices"
- ]
- },
- "execution_count": 8,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "pwd"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 9,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "total 20\n",
- "drwxr-xr-x 5 cyrille 4096 Nov 14 16:16 .\n",
- "drwxr-xr-x 93 cyrille 4096 Dec 12 10:50 ..\n",
- "drwxr-xr-x 2 cyrille 4096 Nov 14 16:16 extensions\n",
- "drwxr-xr-x 2 cyrille 4096 Nov 14 16:16 nbextensions\n",
- "drwxr-xr-x 7 cyrille 4096 Dec 12 14:18 profile_default\n"
- ]
- }
- ],
- "source": [
- "ls -la ~/.ipython"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 10,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "00_intro.md 05_workflows.md\n",
- "01_shell.md 06_tips.md\n",
- "02_py3.md 07_high_quality.md\n",
- "03_git.md 08_test.md\n",
- "04_git_advanced.md 09_debugging.md\n"
- ]
- }
- ],
- "source": [
- "# We create an empty directory:\n",
- "mkdir md_files\n",
- "# We copy all Markdown files into the new directory:\n",
- "cp *.md md_files\n",
- "# We rename the directory:\n",
- "mv md_files markdown_files\n",
- "ls markdown_files"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 11,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "rmdir: failed to remove 'markdown_files':\n",
- " Directory not empty\n"
- ]
- }
- ],
- "source": [
- "rmdir markdown_files"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 12,
- "metadata": {},
- "outputs": [],
- "source": [
- "rm markdown_files/*"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 13,
- "metadata": {},
- "outputs": [],
- "source": [
- "rmdir markdown_files"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 14,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "# Learning the basics of the Unix shell\n",
- "\n",
- "Learning how to interact with the operating system (...)\n"
- ]
- }
- ],
- "source": [
- "# Show the first three lines of a text file:\n",
- "head -n 3 01_shell.md"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 15,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "We will also cover more general topics (...)\n"
- ]
- }
- ],
- "source": [
- "# Show the last line of a text file:\n",
- "tail -n 1 00_intro.md"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 16,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Hello world!\n"
- ]
- }
- ],
- "source": [
- "# We display some text:\n",
- "echo \"Hello world!\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 17,
- "metadata": {},
- "outputs": [],
- "source": [
- "# We redirect the output of a command to\n",
- "# a text file with `>`:\n",
- "echo \"Hello world!\" > myfile.txt"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 18,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Hello world!\n"
- ]
- }
- ],
- "source": [
- "# We display the entire contents of the file:\n",
- "cat myfile.txt"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 19,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Unix shell\n",
- "Unix shell\n",
- "Unix subsystem\n",
- "Unix shell\n",
- "(...)\n",
- "Unix shell\n",
- "Unix shell\n"
- ]
- }
- ],
- "source": [
- "grep -Eo \"Unix \\w+\" 01_shell.md"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 20,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Unix shell\n"
- ]
- }
- ],
- "source": [
- "echo \"This is a Unix shell\" | grep -Eo \"Unix \\w+\""
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.5.2"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
- }
|