From e976b55a5c2a83f4f2ab1221ea228c9b8737db4f Mon Sep 17 00:00:00 2001 From: Simeon Wong Date: Thu, 14 Nov 2024 20:32:09 -0500 Subject: [PATCH 1/8] delete ip logs... WARNING UNTESTED! --- 02_activities/assignments/assignment.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/02_activities/assignments/assignment.sh b/02_activities/assignments/assignment.sh index d81e9a77b..001291867 100644 --- a/02_activities/assignments/assignment.sh +++ b/02_activities/assignments/assignment.sh @@ -33,6 +33,7 @@ unzip rawdata.zip # 6. Repeat the above step for user logs and event logs # 7. For user privacy, remove all files containing IP addresses (files with "ipaddr" in the filename) from ./data/raw and ./data/processed/user_logs +rf -rf ./data # 8. Create a file named ./data/inventory.txt that lists all the files in the subfolders of ./data/processed From ea20676d33161a6f4d0fcd3c4f7aa5360f0f4309 Mon Sep 17 00:00:00 2001 From: Simeon Wong Date: Thu, 14 Nov 2024 20:55:44 -0500 Subject: [PATCH 2/8] initialize README file with company name --- 02_activities/assignments/assignment.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/02_activities/assignments/assignment.sh b/02_activities/assignments/assignment.sh index 001291867..f2bfd22bd 100644 --- a/02_activities/assignments/assignment.sh +++ b/02_activities/assignments/assignment.sh @@ -11,6 +11,7 @@ set -x mkdir analysis output touch README.md +echo "# Project Name: DSI Consulting Inc." > README.md touch analysis/main.py # download client data From 84abfa0f0f7cc75cde657f3669670588d0bfc906 Mon Sep 17 00:00:00 2001 From: lindsaykatz Date: Sun, 19 Jan 2025 16:54:27 -0500 Subject: [PATCH 3/8] add complete homework file --- 02_activities/homework/homework_complete.sh | 60 +++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 02_activities/homework/homework_complete.sh diff --git a/02_activities/homework/homework_complete.sh b/02_activities/homework/homework_complete.sh new file mode 100644 index 000000000..f15e2de82 --- /dev/null +++ b/02_activities/homework/homework_complete.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# On your terminal, input all the commands you have used to create the following: + +# 1. How would you create 5 directories? Feel free to use any name for your directories. +### create a directory to store the homework files +mkdir shell-homework +### make the five directories +mkdir dir1 dir2 dir3 dir4 dir5 +### move them into the shell-homework directory +mv dir* shell-homework + +# 2. How would you verify the creation of all 5 directories? +### change directories to where the 5 directories exist +cd shell-homework +### list the contents of that directory +ls + +# 3. In each directory, how would you create 5 .txt files and write "I love data" into each within the directories? +### create five txt files +touch file1.txt file2.txt file3.txt file4.txt file5.txt + +### append "I love data" to each one +echo "I love data" >> *.txt + +### copy all files ending in .txt into each directory +cp *.txt dir1/ +cp *.txt dir2/ +cp *.txt dir3/ +cp *.txt dir4/ +cp *.txt dir5/ + +# 4. How would you verify the presence of all 5 files? +### list the contents of each directory +ls dir* + +# 5. How would you append to one of the existing files " and machine learning!"? +### example: append " and machine learning!" to third file in first directory +echo " and machine learning!" >> dir1/file3.txt + +# 6. How would you verify that the text was indeed appended to the existing file? +cat dir1/file3.txt + +# 7. How would you delete all files except for the one with the appended text? +### I would move the file of interest and remove everything else +mv dir1/file3.txt shell-homework/file3.txt + +### recursively remove all directories +rm -R dir* + +# 8. How would you navigate back to the parent directory containing all the directories? +cd + +# 9. How would you remove each directory along with its contents? +### recursive remove +# rm -R * + +# 10. How would you verify that all directories and files have been deleted? +### relist contents, there should be no output +ls From 9248511a75be88555bc4b22f74ac1d7938250bd3 Mon Sep 17 00:00:00 2001 From: lindsaykatz Date: Sun, 19 Jan 2025 16:55:47 -0500 Subject: [PATCH 4/8] add complete assignment script --- .../assignments/assignment_complete.sh | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 02_activities/assignments/assignment_complete.sh diff --git a/02_activities/assignments/assignment_complete.sh b/02_activities/assignments/assignment_complete.sh new file mode 100644 index 000000000..e0e74051f --- /dev/null +++ b/02_activities/assignments/assignment_complete.sh @@ -0,0 +1,54 @@ +#!/bin/bash +set -x + +############################################ +# DSI CONSULTING INC. Project setup script # +############################################ +# This script creates standard analysis and output directories +# for a new project. It also creates a README file with the +# project name and a brief description of the project. +# Then it unzips the raw data provided by the client. + +mkdir analysis output +touch README.md +touch analysis/main.py + +# download client data +curl -Lo rawdata.zip https://github.com/UofT-DSI/shell/raw/refs/heads/main/02_activities/assignments/rawdata.zip +unzip rawdata.zip + +########################################### +# Complete assignment here + +# 1. Create a directory named data +mkdir data + +# 2. Move the ./rawdata directory to ./data/raw +cd data +mv ../rawdata raw + +# 3. List the contents of the ./data/raw directory +ls raw + +# 4. In ./data/processed, create the following directories: server_logs, user_logs, and event_logs +mkdir processed +mkdir processed/server_logs processed/user_logs processed/event_logs + +# 5. Copy all server log files (files with "server" in the name AND a .log extension) from ./data/raw to ./data/processed/server_logs +cp raw/*server*.log processed/server_logs + +# 6. Repeat the above step for user logs and event logs +cp raw/*user*.log processed/user_logs +cp raw/*event*.log processed/event_logs + +# 7. For user privacy, remove all files containing IP addresses (files with "ipaddr" in the filename) from ./data/raw and ./data/processed/user_logs +rm raw/*ipaddr*.log +rm processed/user_logs/*ipaddr*.log + +# 8. Create a file named ./data/inventory.txt that lists all the files in the subfolders of ./data/processed +touch inventory.txt +ls processed/* >> inventory.txt + +########################################### + +echo "Project setup is complete!" From 8308816edbb2f4edb8959e366f2b6b95793ae782 Mon Sep 17 00:00:00 2001 From: lindsaykatz Date: Sun, 19 Jan 2025 16:59:06 -0500 Subject: [PATCH 5/8] rename completed assignment file --- 02_activities/assignments/assignment.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/02_activities/assignments/assignment.sh b/02_activities/assignments/assignment.sh index 0d2bf96b1..e0e74051f 100644 --- a/02_activities/assignments/assignment.sh +++ b/02_activities/assignments/assignment.sh @@ -11,7 +11,6 @@ set -x mkdir analysis output touch README.md -echo "# Project Name: DSI Consulting Inc." > README.md touch analysis/main.py # download client data @@ -22,23 +21,33 @@ unzip rawdata.zip # Complete assignment here # 1. Create a directory named data +mkdir data # 2. Move the ./rawdata directory to ./data/raw +cd data +mv ../rawdata raw # 3. List the contents of the ./data/raw directory +ls raw # 4. In ./data/processed, create the following directories: server_logs, user_logs, and event_logs +mkdir processed +mkdir processed/server_logs processed/user_logs processed/event_logs # 5. Copy all server log files (files with "server" in the name AND a .log extension) from ./data/raw to ./data/processed/server_logs +cp raw/*server*.log processed/server_logs # 6. Repeat the above step for user logs and event logs +cp raw/*user*.log processed/user_logs +cp raw/*event*.log processed/event_logs # 7. For user privacy, remove all files containing IP addresses (files with "ipaddr" in the filename) from ./data/raw and ./data/processed/user_logs -rf -rf ./data +rm raw/*ipaddr*.log +rm processed/user_logs/*ipaddr*.log # 8. Create a file named ./data/inventory.txt that lists all the files in the subfolders of ./data/processed - - +touch inventory.txt +ls processed/* >> inventory.txt ########################################### From 74647b49037499aeee43edff408087d9bac4be86 Mon Sep 17 00:00:00 2001 From: lindsaykatz Date: Sun, 19 Jan 2025 16:59:40 -0500 Subject: [PATCH 6/8] delete old assignment file --- .../assignments/assignment_complete.sh | 54 ------------------- 1 file changed, 54 deletions(-) delete mode 100644 02_activities/assignments/assignment_complete.sh diff --git a/02_activities/assignments/assignment_complete.sh b/02_activities/assignments/assignment_complete.sh deleted file mode 100644 index e0e74051f..000000000 --- a/02_activities/assignments/assignment_complete.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -set -x - -############################################ -# DSI CONSULTING INC. Project setup script # -############################################ -# This script creates standard analysis and output directories -# for a new project. It also creates a README file with the -# project name and a brief description of the project. -# Then it unzips the raw data provided by the client. - -mkdir analysis output -touch README.md -touch analysis/main.py - -# download client data -curl -Lo rawdata.zip https://github.com/UofT-DSI/shell/raw/refs/heads/main/02_activities/assignments/rawdata.zip -unzip rawdata.zip - -########################################### -# Complete assignment here - -# 1. Create a directory named data -mkdir data - -# 2. Move the ./rawdata directory to ./data/raw -cd data -mv ../rawdata raw - -# 3. List the contents of the ./data/raw directory -ls raw - -# 4. In ./data/processed, create the following directories: server_logs, user_logs, and event_logs -mkdir processed -mkdir processed/server_logs processed/user_logs processed/event_logs - -# 5. Copy all server log files (files with "server" in the name AND a .log extension) from ./data/raw to ./data/processed/server_logs -cp raw/*server*.log processed/server_logs - -# 6. Repeat the above step for user logs and event logs -cp raw/*user*.log processed/user_logs -cp raw/*event*.log processed/event_logs - -# 7. For user privacy, remove all files containing IP addresses (files with "ipaddr" in the filename) from ./data/raw and ./data/processed/user_logs -rm raw/*ipaddr*.log -rm processed/user_logs/*ipaddr*.log - -# 8. Create a file named ./data/inventory.txt that lists all the files in the subfolders of ./data/processed -touch inventory.txt -ls processed/* >> inventory.txt - -########################################### - -echo "Project setup is complete!" From b0788a934b5030b7aa060de6a5b68c887d44078c Mon Sep 17 00:00:00 2001 From: lindsaykatz Date: Tue, 21 Jan 2025 19:38:23 -0500 Subject: [PATCH 7/8] assignment fixes --- 02_activities/assignments/assignment.sh | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/02_activities/assignments/assignment.sh b/02_activities/assignments/assignment.sh index e0e74051f..f1c34415b 100644 --- a/02_activities/assignments/assignment.sh +++ b/02_activities/assignments/assignment.sh @@ -24,30 +24,28 @@ unzip rawdata.zip mkdir data # 2. Move the ./rawdata directory to ./data/raw -cd data -mv ../rawdata raw +mv rawdata data/raw # 3. List the contents of the ./data/raw directory -ls raw +ls ./data/raw # 4. In ./data/processed, create the following directories: server_logs, user_logs, and event_logs -mkdir processed -mkdir processed/server_logs processed/user_logs processed/event_logs +mkdir -p ./data/processed/server_logs ./data/processed/user_logs ./data/processed/event_logs # 5. Copy all server log files (files with "server" in the name AND a .log extension) from ./data/raw to ./data/processed/server_logs -cp raw/*server*.log processed/server_logs +cp ./data/raw/*server*.log ./data/processed/server_logs # 6. Repeat the above step for user logs and event logs -cp raw/*user*.log processed/user_logs -cp raw/*event*.log processed/event_logs +cp ./data/raw/*user*.log ./data/processed/user_logs +cp ./data/raw/*event*.log ./data/processed/event_logs # 7. For user privacy, remove all files containing IP addresses (files with "ipaddr" in the filename) from ./data/raw and ./data/processed/user_logs -rm raw/*ipaddr*.log -rm processed/user_logs/*ipaddr*.log +rm ./data/raw/*ipaddr* +rm ./data/processed/user_logs/*ipaddr* # 8. Create a file named ./data/inventory.txt that lists all the files in the subfolders of ./data/processed touch inventory.txt -ls processed/* >> inventory.txt +ls ./data/processed/* >> inventory.txt ########################################### From c42c92f9ea97203771df6709eb2dd47a00d12bfa Mon Sep 17 00:00:00 2001 From: lindsaykatz Date: Tue, 21 Jan 2025 19:43:56 -0500 Subject: [PATCH 8/8] final fix on assignment, last q --- 02_activities/assignments/assignment.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/02_activities/assignments/assignment.sh b/02_activities/assignments/assignment.sh index f1c34415b..2a7acd2ca 100644 --- a/02_activities/assignments/assignment.sh +++ b/02_activities/assignments/assignment.sh @@ -44,8 +44,8 @@ rm ./data/raw/*ipaddr* rm ./data/processed/user_logs/*ipaddr* # 8. Create a file named ./data/inventory.txt that lists all the files in the subfolders of ./data/processed -touch inventory.txt -ls ./data/processed/* >> inventory.txt +touch ./data/inventory.txt +ls ./data/processed/* >> ./data/inventory.txt ###########################################