Skip to content

Commit 07caeed

Browse files
Add files via upload
assignment
1 parent 7a0d963 commit 07caeed

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

assignment.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
set -x
3+
4+
############################################
5+
# DSI CONSULTING INC. Project setup script #
6+
############################################
7+
# This script creates standard analysis and output directories
8+
# for a new project. It also creates a README file with the
9+
# project name and a brief description of the project.
10+
# Then it unzips the raw data provided by the client.
11+
12+
if [ -d newproject ]; then
13+
echo "Recreating the newproject directory"
14+
rm -rf newproject
15+
fi
16+
mkdir newproject
17+
cd newproject
18+
19+
mkdir analysis output
20+
touch README.md
21+
touch analysis/main.py
22+
23+
# download client data
24+
curl -Lo rawdata.zip https://github.com/UofT-DSI/shell/raw/refs/heads/main/02_activities/assignments/rawdata.zip
25+
unzip -q rawdata.zip
26+
27+
###########################################
28+
# Complete assignment here
29+
30+
# 1. Create a directory named data
31+
mkdir data
32+
33+
# 2. Move the ./rawdata directory to ./data/raw
34+
35+
mkdir data/raw
36+
mv rawdata/* data/raw/
37+
38+
39+
# 3. List the contents of the ./data/raw directory
40+
ls data/raw
41+
42+
# 4. In ./data/processed, create the following directories: server_logs, user_logs, and event_logs
43+
44+
mkdir -p data/processed/{server_logs,user_logs,event_logs}
45+
46+
# 5. Copy all server log files (files with "server" in the name AND a .log extension) from ./data/raw to ./data/processed/server_logs
47+
48+
cp data/raw/server*.log data/processed/server_logs/
49+
50+
# 6. Repeat the above step for user logs and event logs
51+
52+
53+
cp data/raw/event*.log data/processed/event_logs/
54+
cp data/raw/user*.log data/processed/user_logs/
55+
56+
# 7. For user privacy, remove all files containing IP addresses (files with "ipaddr" in the filename) from ./data/raw and ./data/processed/user_logs
57+
58+
rm -f data/raw/*ipaddr*
59+
rm -f data/processed/user_logs/*ipaddr*
60+
61+
# 8. Create a file named ./data/inventory.txt that lists all the files in the subfolders of ./data/processed
62+
63+
find data/processed -type f > data/inventory.txt
64+
65+
###########################################
66+
67+
echo "Project setup is complete!"

0 commit comments

Comments
 (0)