From ff54916f595691968b50edcd8dbcf9e670b68e7e Mon Sep 17 00:00:00 2001 From: Muriel Berkenstock Date: Mon, 3 Oct 2022 17:46:32 +0200 Subject: [PATCH 1/2] added files from lab 1 --- lorem/at.txt | 4 ++- lorem_copy/at.txt | 10 +++++++ lorem_copy/lorem.txt | 4 +++ lorem_copy/sed.txt | 11 ++++++++ solutions.ipynb | 66 ++++++++++++++++++++++++-------------------- 5 files changed, 64 insertions(+), 31 deletions(-) create mode 100644 lorem_copy/at.txt create mode 100644 lorem_copy/lorem.txt create mode 100644 lorem_copy/sed.txt diff --git a/lorem/at.txt b/lorem/at.txt index 4b7e1e4..a795700 100644 --- a/lorem/at.txt +++ b/lorem/at.txt @@ -7,4 +7,6 @@ maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repell Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores -alias consequatur aut perferendis doloribus asperiores repellat \ No newline at end of file +alias consequatur aut perferendis doloribus asperiores repellat +doi + diff --git a/lorem_copy/at.txt b/lorem_copy/at.txt new file mode 100644 index 0000000..4b7e1e4 --- /dev/null +++ b/lorem_copy/at.txt @@ -0,0 +1,10 @@ +At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum +deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non +provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. +Et harum quidem rerum facilis est et expedita distinctio. +Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod +maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. +Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet +ut et voluptates repudiandae sint et molestiae non recusandae. +Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores +alias consequatur aut perferendis doloribus asperiores repellat \ No newline at end of file diff --git a/lorem_copy/lorem.txt b/lorem_copy/lorem.txt new file mode 100644 index 0000000..3d79369 --- /dev/null +++ b/lorem_copy/lorem.txt @@ -0,0 +1,4 @@ +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. +Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. +Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. +Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. \ No newline at end of file diff --git a/lorem_copy/sed.txt b/lorem_copy/sed.txt new file mode 100644 index 0000000..167e0f0 --- /dev/null +++ b/lorem_copy/sed.txt @@ -0,0 +1,11 @@ +Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, +totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. +Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, +sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. +Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, +sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. +Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, +nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, +vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? Homo homini +lupus + diff --git a/solutions.ipynb b/solutions.ipynb index 10ae56f..edd90fa 100644 --- a/solutions.ipynb +++ b/solutions.ipynb @@ -22,7 +22,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: echo \"Hello World\"" ] }, { @@ -38,7 +38,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: mkdir new_dir" ] }, { @@ -54,7 +54,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: rm -r new_dir" ] }, { @@ -70,7 +70,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: echo \"Hello World\"" ] }, { @@ -86,7 +86,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: mkdir new_dir" ] }, { @@ -102,7 +102,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: rm -r new_dir" ] }, { @@ -118,7 +118,9 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: cd lorem\n", + "mkdir lorem_copy\n", + "cp lorem/sed.txt lorem_copy/" ] }, { @@ -134,7 +136,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: cp lorem/at.txt lorem_copy; cp lorem/lorem.txt lorem_copy/" ] }, { @@ -150,7 +152,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: cd lorem ; cat sed.txt" ] }, { @@ -166,7 +168,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: cat at.txt; cat lorem.txt" ] }, { @@ -182,7 +184,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: cd lorem_copy ; head -3 sed.txt " ] }, { @@ -198,7 +200,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: cd lorem_copy; tail -3 sed.txt " ] }, { @@ -214,7 +216,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: cd lorem_copy; nano Homo homini lupus " ] }, { @@ -230,7 +232,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: *keeping in mind the current directory remains lorem_copy* tail -3 sed.txt" ] }, { @@ -246,7 +248,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: sed 's/et/ET/' at.txt" ] }, { @@ -262,7 +264,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: users " ] }, { @@ -278,7 +280,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: pwd" ] }, { @@ -294,7 +296,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: cd lorem; ls ./*.txt" ] }, { @@ -310,7 +312,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: wc -l sed.txt" ] }, { @@ -326,7 +328,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: ls lorem | wc -l ; ls lorem_copy | wc -l; ls | wc -l " ] }, { @@ -342,7 +344,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: cd lorem; grep \"et\" at.txt\n" ] }, { @@ -358,7 +360,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: grep \"et\" at.txt | wc -w" ] }, { @@ -374,7 +376,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: cd lorem_copy ; grep -o \"et\" *.txt | wc -l\n" ] }, { @@ -397,7 +399,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: name=Cason " ] }, { @@ -413,7 +415,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: echo $name" ] }, { @@ -429,7 +431,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: mkdir $name" ] }, { @@ -445,7 +447,7 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: rm -r $name" ] }, { @@ -465,7 +467,11 @@ "cell_type": "raw", "metadata": {}, "source": [ - "The command:" + "The command: cd lorem ; for file in * ; do\n", + " echo -n \"$file \"\n", + " character= echo -n \"$file\" | wc -c\n", + " echo \" has: \" $character \n", + "done \n" ] }, { @@ -570,7 +576,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -584,7 +590,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.12" + "version": "3.7.6" }, "nbTranslate": { "displayLangs": [ From b4921069aea1a2f533c41741d043a549dea9381f Mon Sep 17 00:00:00 2001 From: Muriel Berkenstock Date: Mon, 3 Oct 2022 17:59:10 +0200 Subject: [PATCH 2/2] lab 1 --- lab1.ipynb | 622 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 622 insertions(+) create mode 100644 lab1.ipynb diff --git a/lab1.ipynb b/lab1.ipynb new file mode 100644 index 0000000..edd90fa --- /dev/null +++ b/lab1.ipynb @@ -0,0 +1,622 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "### Exercises" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Print Hello World to console." + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The command: echo \"Hello World\"" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Create a new directory called new_dir." + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The command: mkdir new_dir" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Delete that directory." + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The command: rm -r new_dir" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Print Hello World to console." + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The command: echo \"Hello World\"" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Create a new directory called new_dir." + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The command: mkdir new_dir" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Delete that directory." + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The command: rm -r new_dir" + ] + }, + { + "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": "raw", + "metadata": {}, + "source": [ + "The command: cd lorem\n", + "mkdir lorem_copy\n", + "cp lorem/sed.txt lorem_copy/" + ] + }, + { + "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": "raw", + "metadata": {}, + "source": [ + "The command: cp lorem/at.txt lorem_copy; cp lorem/lorem.txt lorem_copy/" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Shows the content of the sed.txt file inside the lorem folder." + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The command: cd lorem ; cat sed.txt" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Shows the contents of the at.txt and lorem.txt files inside the lorem folder." + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The command: cat at.txt; cat lorem.txt" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Display the first 3 lines of the sed.txt file inside the lorem-copy folder" + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The command: cd lorem_copy ; head -3 sed.txt " + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### View the last 3 lines of the sed.txt file inside the lorem-copy folder" + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The command: cd lorem_copy; tail -3 sed.txt " + ] + }, + { + "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": "raw", + "metadata": {}, + "source": [ + "The command: cd lorem_copy; nano Homo homini lupus " + ] + }, + { + "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": "raw", + "metadata": {}, + "source": [ + "The command: *keeping in mind the current directory remains lorem_copy* tail -3 sed.txt" + ] + }, + { + "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": "raw", + "metadata": {}, + "source": [ + "The command: sed 's/et/ET/' at.txt" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Find the active user on the system." + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The command: users " + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Find where you are in your file system." + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The command: pwd" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### List files ending with .txt in the lorem folder." + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The command: cd lorem; ls ./*.txt" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Counts the number of lines in the sed.txt file inside the lorem folder." + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The command: wc -l sed.txt" + ] + }, + { + "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": "raw", + "metadata": {}, + "source": [ + "The command: ls lorem | wc -l ; ls lorem_copy | wc -l; ls | wc -l " + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Find all occurrences of et in at.txt inside the lorem folder." + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The command: cd lorem; grep \"et\" at.txt\n" + ] + }, + { + "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": "raw", + "metadata": {}, + "source": [ + "The command: grep \"et\" at.txt | wc -w" + ] + }, + { + "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": "raw", + "metadata": {}, + "source": [ + "The command: cd lorem_copy ; grep -o \"et\" *.txt | wc -l\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### BONUS" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Store your name in a name variable." + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The command: name=Cason " + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Print that variable." + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The command: echo $name" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Create a new directory named as the content of the name variable." + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The command: mkdir $name" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Delete that directory." + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The command: rm -r $name" + ] + }, + { + "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": "raw", + "metadata": {}, + "source": [ + "The command: cd lorem ; for file in * ; do\n", + " echo -n \"$file \"\n", + " character= echo -n \"$file\" | wc -c\n", + " echo \" has: \" $character \n", + "done \n" + ] + }, + { + "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": "raw", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Displays information about your processor on the screen" + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "The command:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "lang": "en" + }, + "source": [ + "#### Create 3 aliases and make them available every time you login" + ] + }, + { + "cell_type": "raw", + "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": "raw", + "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": "raw", + "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": "raw", + "metadata": {}, + "source": [ + "The command:" + ] + } + ], + "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.7.6" + }, + "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 +}