From 859f585a19e3fd4783ed1ddf457715e36553db57 Mon Sep 17 00:00:00 2001 From: Lorenzo Castro De Salvo Date: Mon, 2 Mar 2026 18:58:08 +0100 Subject: [PATCH 1/2] HW1 --- script.sh | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/script.sh b/script.sh index 4a708d8..11cde02 100755 --- a/script.sh +++ b/script.sh @@ -20,24 +20,26 @@ echo "" # 0. Tell me who worked on this together -echo "student 1" # please fill in names here -echo "student 2" +echo "Lorenzo Castro" # please fill in names here +echo "Caterina de gaetano" # here is a list of tasks for you. # whenever a line says "don't touch" then you are not supposed to touch what comes below. # all lines where you need to take action are numbered. # 1. Go to your home directory: - +cd # 2. from your home, creating a directory structure: new folder `programming-hw`, and inside that folder create folder `hw1` - +mkdir -p ~/programming-hw/hw1 # 3. go into that new directory, i.e. into ~/programming-hw/hw1 +cd ~/programming-hw/hw1 # checking the folder exists now # don't touch [ -d ~/programming-hw/hw1 ] && echo "directory created successfully" || exit 1 + # download with wget if file does not exist yet # if wget does not work for you, manually download from the below URL and place into `~/programming-hw/hw1` as `movies.dat` # first let me check whether you have wget installed and install it otherwise for you: @@ -60,10 +62,11 @@ if [ ! -f movies.dat ]; then fi # 4. look at first 4 rows of downloaded data in `movies.dat`. look at this output and try to understand how it is structured. the file ending is `dat`. however, how could you also denominate such a file? - +head -n 4 movies.dat +## it could be reanamed as txt file # 5. look at first 4 rows of downloaded data in `movies.dat` redirect to a file called `first4.txt` - +head -n 4 movies.dat > first4.txt # don't touch if [ ! -f first4.txt ]; then @@ -94,6 +97,8 @@ echo "" # awk -F '::' '{print $3}' _filename_ +awk -F '::' '{print $3}' movies.dat + # 7. observe that the `{print $3}` part prints the third field. that looks like: genre1|genre2 # that is, there is *another* separator in this column, `|`. Let's separate again. copy your command from above and # add a pipe as follows. here, the second statement will split at `|` and print into *how many parts* it has split. @@ -101,6 +106,7 @@ echo "" # again, remove the # below, fill in for _filename_ and run # awk -F '::' '{print $3}' _filename_ | awk '{print split($0, a, "\\|")}' +awk -F '::' '{print $3}' movies.dat | awk '{print split($0, a, "\\|")}' # 8. finish the pipeline by adding 2 commands, exactly like in class, that will produce a contingency table @@ -108,8 +114,11 @@ echo "" # awk -F '::' '{print $3}' _filename_ | awk '{print split($0, a, "\\|")}' | sort | uniq -c +awk -F '::' '{print $3}' movies.dat | awk '{print split($0, a, "\\|")}' | sort | uniq -c + # 9. redirect (>) the output of your pipeline to a file `outtable.txt` in the current directory +awk -F '::' '{print $3}' movies.dat | awk '{print split($0, a, "\\|")}' | sort | uniq -c > outtable.txt # dont touch echo "" # leave this untouched @@ -117,7 +126,7 @@ echo "here is my table:" # this as well # 10. Print your table to screen - +cat outtable.txt #### End of your tasks # please do not modify the below lines From 8ea8dfa74ba9b01529f54a9d4c0ea34ccbceb148 Mon Sep 17 00:00:00 2001 From: Lorenzo Castro De Salvo Date: Tue, 3 Mar 2026 22:48:08 +0100 Subject: [PATCH 2/2] My Homework1 --- script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.sh b/script.sh index 11cde02..ce25bd2 100755 --- a/script.sh +++ b/script.sh @@ -22,7 +22,7 @@ echo "" # 0. Tell me who worked on this together echo "Lorenzo Castro" # please fill in names here echo "Caterina de gaetano" - +echo "Paolo Dioatallevi" # here is a list of tasks for you. # whenever a line says "don't touch" then you are not supposed to touch what comes below. # all lines where you need to take action are numbered.