Jupyter Snippet CB2nd 01_shell

Jupyter Snippet CB2nd 01_shell

2.1. Learning the basics of the Unix shell

pwd
~/git/cookbook-2nd/chapter02_best_practices
ls
00_intro.md  03_git.md           07_high_quality.md
01_shell.md  04_git_advanced.md  08_test.md
02_py3       05_workflows.md     09_debugging.md
02_py3.md    06_tips.md          images
ls -l
total 100
-rw-rw-r-- 1 owner   769 Dec 12 10:23 00_intro.md
-rw-rw-r-- 1 owner  2473 Dec 12 14:21 01_shell.md
...
-rw-rw-r-- 1 owner  9390 Dec 12 11:46 08_test.md
-rw-rw-r-- 1 owner  5032 Dec 12 10:23 09_debugging.md
drwxrwxr-x 2 owner  4096 Aug  1 16:49 images
cd images
pwd
~/git/cookbook-2nd/chapter02_best_practices/images
ls
folder.png  github_new.png
cd ..
pwd
~/git/cookbook-2nd/chapter02_best_practices
ls -la ~/.ipython
total 20
drwxr-xr-x  5 cyrille 4096 Nov 14 16:16 .
drwxr-xr-x 93 cyrille 4096 Dec 12 10:50 ..
drwxr-xr-x  2 cyrille 4096 Nov 14 16:16 extensions
drwxr-xr-x  2 cyrille 4096 Nov 14 16:16 nbextensions
drwxr-xr-x  7 cyrille 4096 Dec 12 14:18 profile_default
# We create an empty directory:
mkdir md_files
# We copy all Markdown files into the new directory:
cp *.md md_files
# We rename the directory:
mv md_files markdown_files
ls markdown_files
00_intro.md         05_workflows.md
01_shell.md         06_tips.md
02_py3.md           07_high_quality.md
03_git.md           08_test.md
04_git_advanced.md  09_debugging.md
rmdir markdown_files
rmdir: failed to remove 'markdown_files':
    Directory not empty
rm markdown_files/*
rmdir markdown_files
# Show the first three lines of a text file:
head -n 3 01_shell.md
# Learning the basics of the Unix shell

Learning how to interact with the operating system (...)
# Show the last line of a text file:
tail -n 1 00_intro.md
We will also cover more general topics (...)
# We display some text:
echo "Hello world!"
Hello world!
# We redirect the output of a command to
# a text file with `>`:
echo "Hello world!" > myfile.txt
# We display the entire contents of the file:
cat myfile.txt
Hello world!
grep -Eo "Unix \w+" 01_shell.md
Unix shell
Unix shell
Unix subsystem
Unix shell
(...)
Unix shell
Unix shell
echo "This is a Unix shell" | grep -Eo "Unix \w+"
Unix shell