diff --git a/example.txt b/example.txt new file mode 100644 index 0000000..e69de29 diff --git a/solutions.ipynb b/solutions.ipynb index 2c6ecf3..2c680e1 100644 --- a/solutions.ipynb +++ b/solutions.ipynb @@ -19,10 +19,10 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: echo \"Hello World\"" ] }, { @@ -35,10 +35,10 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: mkdir new_dir" ] }, { @@ -51,10 +51,10 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: rm -r new_dir" ] }, { @@ -67,10 +67,12 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: mkdir lorem-copy\n", + "cd lorem\n", + "cp sed.txt ../lorem-copy/" ] }, { @@ -83,10 +85,10 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: cp at.txt ../lorem-copy/; cp lorem.txt ../lorem-copy/" ] }, { @@ -99,10 +101,10 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: cat sed.txt" ] }, { @@ -115,10 +117,10 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: cat at.txt; cat lorem.txt" ] }, { @@ -131,10 +133,13 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: \n", + "cd ..\n", + "cd lorem-copy\n", + "head -3 sed.txt" ] }, { @@ -147,10 +152,11 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command:\n", + "tail -3 sed.txt" ] }, { @@ -163,10 +169,13 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command:\n", + "\n", + "echo \"Homo homini lupus\" >> sed.txt\n", + "cat sed.txt (to check)" ] }, { @@ -179,10 +188,11 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command:\n", + "tail -3 sed.txt" ] }, { @@ -195,10 +205,16 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command:\n", + "sed -i -e 's/et/ET/g' at.txt\n", + "\n", + "this works but also creates a new file (at.txt-e) which I can't open\n", + "also adding: \n", + "\n", + "rm at.txt-e" ] }, { @@ -211,10 +227,11 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command:\n", + "whoami" ] }, { @@ -227,10 +244,11 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: \n", + "pwd" ] }, { @@ -243,10 +261,11 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: \n", + "git ls-files '*.txt'" ] }, { @@ -259,10 +278,11 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command:\n", + "wc sed.txt" ] }, { @@ -275,10 +295,13 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command:\n", + "cd ..\n", + "cd ..\n", + "find . -name 'lorem*' | wc -l" ] }, { @@ -291,10 +314,14 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command:\n", + "cd lab-bash\n", + "cd lorem\n", + "\n", + "grep -o \"et\" at.txt" ] }, { @@ -307,10 +334,11 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command:\n", + "grep -o \"et\" at.txt | wc -l" ] }, { @@ -323,10 +351,12 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command:\n", + "\n", + "grep 'et' ./lorem-copy/*.* | wc -l\n" ] }, { @@ -346,10 +376,11 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command:\n", + "name=Edu" ] }, { @@ -362,10 +393,11 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command:\n", + "echo $name" ] }, { @@ -378,10 +410,11 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: \n", + "mkdir $name" ] }, { @@ -394,10 +427,11 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command:\n", + "rm -r $name" ] }, { @@ -414,10 +448,29 @@ ] }, { - "cell_type": "markdown", + "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command:\n", + "\n", + "to print the file names:\n", + "for i in *\n", + "do\n", + " echo $i\n", + "done\n", + "\n", + "length of file names: \n", + "\n", + "for i in *\n", + "do\n", + " ${#i}\n", + "done\n", + "\n", + "to print outputs:\n", + "\n", + "for i in *\n", + "> do echo $i \"has\" ${#i} \"characters length\"\n", + "> done" ] }, { @@ -536,7 +589,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.8" + "version": "3.11.4" }, "nbTranslate": { "displayLangs": [ diff --git a/solutions2.ipynb b/solutions2.ipynb new file mode 100644 index 0000000..2c6ecf3 --- /dev/null +++ b/solutions2.ipynb @@ -0,0 +1,568 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "### Exercises" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Print Hello World to console." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Create a new directory called new_dir." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Delete that directory." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Copy the sed.txt file inside the lorem folder to the lorem-copy folder (you might need to look the documentation up)." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Copy the other two files from the lorem folder to the lorem-copy folder in a single line using ;." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Shows the content of the sed.txt file inside the lorem folder." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Shows the contents of the at.txt and lorem.txt files inside the lorem folder." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Display the first 3 lines of the sed.txt file inside the lorem-copy folder" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### View the last 3 lines of the sed.txt file inside the lorem-copy folder" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Add Homo homini lupus. at the end of the sed.txt file inside the lorem-copy folder." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Display the last 3 lines of the sed.txt file inside the lorem-copy folder. You should now see Homo homini lupus" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Replaces all occurrences of et with ET from the at.txt file inside the lorem-copy folder. You should use sed." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Find the active user on the system." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Find where you are in your file system." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### List files ending with .txt in the lorem folder." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Counts the number of lines in the sed.txt file inside the lorem folder." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Counts the number of files starting with lorem that are in this directory and in internal directories." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Find all occurrences of et in at.txt inside the lorem folder." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Counts the number of occurrences of the string et in at.txt inside the lorem folder." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Counts the number of occurrences of the string et in all files in the lorem-copy directory." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### BONUS" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Store your name in a name variable." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Print that variable." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Create a new directory named as the content of the name variable." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Delete that directory." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### For each file inside the folder lorem prints the number of characters their names have. First try to display the files using a for loop:\n", + "\n", + "- Print the files\n", + "- Print the lengths of the file names\n", + "- Print outputs with the following structure: lorem has 5 characters length" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Shows the processes in a hierarchical way that are running on your computer:\n", + "\n", + "- Using the top or htop command\n", + "- Using the ps command with arguments" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Displays information about your processor on the screen" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Create 3 aliases and make them available every time you login" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Compress the lorem and lorem-copy folders into a file called lorem-compressed.tar.gz" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Unpack the lorem-compressed.tar.gz file into the lorem-uncompressed folder" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Unpack the lorem-compressed.tar.gz file into the lorem-uncompressed folder" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The command:" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.10.8" + }, + "nbTranslate": { + "displayLangs": [ + "en", + "es" + ], + "hotkey": "alt-a", + "langInMainMenu": true, + "sourceLang": "es", + "targetLang": "en", + "useGoogleTranslate": true + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": true, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false + } + }, + "nbformat": 4, + "nbformat_minor": 4 +}