diff --git a/02_activities/assignments/assignment.sh b/02_activities/assignments/assignment.sh index d81e9a77b..12ebf784b 100644 --- a/02_activities/assignments/assignment.sh +++ b/02_activities/assignments/assignment.sh @@ -11,32 +11,43 @@ set -x mkdir analysis output touch README.md +echo "# Project Name: DSI Consulting Inc." > README.md touch analysis/main.py # download client data -wget -O rawdata.zip https://github.com/UofT-DSI/shell/raw/refs/heads/main/02_activities/assignments/rawdata.zip +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 +# 1. Create a directory named data +mkdir data -# 2. Move the ./rawdata directory to ./data/raw + +# 2. Move the ./rawdata directory to ./data/raw +mv rawdata data/raw # 3. List the contents of the ./data/raw directory +ls data/raw -# 4. In ./data/processed, create the following directories: server_logs, user_logs, and event_logs +# 4. In ./data/processed, create the following directories: server_logs, user_logs, and 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 data/raw/*server*.log data/processed/server_logs # 6. Repeat the above step for user logs and 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 data/raw/*ipaddr* data/processed/user_logs/*ipaddr* # 8. Create a file named ./data/inventory.txt that lists all the files in the subfolders of ./data/processed - +ls -R data/processed > data/inventory.txt ########################################### diff --git a/02_activities/homework/homework.sh b/02_activities/homework/homework.sh index a43292248..56af87896 100644 --- a/02_activities/homework/homework.sh +++ b/02_activities/homework/homework.sh @@ -3,21 +3,35 @@ # 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. +mkdir dir1 dir2 dir3 dir4 dir5 # 2. How would you verify the creation of all 5 directories? +ls # 3. In each directory, how would you create 5 .txt files and write "I love data" into each within the directories? +for dir in dir1 dir2 dir3 dir4 dir5; do + for i in {1..5}; do + echo "I love data" > "$dir/file$i.txt" + done +done # 4. How would you verify the presence of all 5 files? +ls dir1 dir2 dir3 dir4 dir5 # 5. How would you append to one of the existing files " and machine learning!"? +echo " and machine learning!" >> dir1/file1.txt # 6. How would you verify that the text was indeed appended to the existing file? +cat dir1/file1.txt -# 7. How would you delete all files except for the one with the appended text? +# # 7. How would you delete all files except for the one with the appended text? +find dir1 dir2 dir3 dir4 dir5 -type f -name "*.txt" ! -exec grep -q "and machine learning!" {} \; -delete # 8. How would you navigate back to the parent directory containing all the directories? +cd ~/Desktop/DSI/shell/02_activities/homework # 9. How would you remove each directory along with its contents? +rm -r dir1 dir2 dir3 dir4 dir5 # 10. How would you verify that all directories and files have been deleted? +ls