From b5b639554c532ab2a9b9cc48ef3db282ef0a2d60 Mon Sep 17 00:00:00 2001 From: Mirco Tucci Date: Sun, 1 Mar 2026 13:21:03 +0100 Subject: [PATCH 1/2] Mirco Tucci and Davide Raciti's hw1 --- script.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/script.sh b/script.sh index 4a708d8..e5ce046 100755 --- a/script.sh +++ b/script.sh @@ -20,20 +20,20 @@ echo "" # 0. Tell me who worked on this together -echo "student 1" # please fill in names here -echo "student 2" +echo "Mirco Tucci" # please fill in names here +echo "Davide Raciti" # 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 @@ -60,10 +60,10 @@ 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 +# file csv? ma non c'è la virgola, ci sono i :: come delimitatori. # 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 @@ -92,7 +92,7 @@ echo "" # fill in for _filename_ the correct file you want to operate on. # then remove the # character from the start of the line and look at the result -# 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 @@ -100,16 +100,16 @@ echo "" # i.e. it will tell us *how many genres* that movie belonged to. No need to understand the `awk` part. # 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 # we want to know how many movies belong to 0,1,2,... etc genres. -# 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 +117,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 e5ab15c2c88131bd3672a58ea65457917cf5dfda Mon Sep 17 00:00:00 2001 From: Mirco Tucci Date: Sun, 1 Mar 2026 13:32:23 +0100 Subject: [PATCH 2/2] Mirco Tucci and Davide Raciti's hw1 --- script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.sh b/script.sh index e5ce046..b4ddb73 100755 --- a/script.sh +++ b/script.sh @@ -61,7 +61,7 @@ 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 -# file csv? ma non c'è la virgola, ci sono i :: come delimitatori. +# It should be a kind of csv file, but with a different separator. The separator is `::`. # 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