Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Bash-Assignment
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
John Lam
Bash-Assignment
Commits
21172507
Commit
21172507
authored
Mar 28, 2021
by
vagrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed associated map for q-5
parent
ea8bc5e0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
10 deletions
+30
-10
5-generate-report.sh
5-generate-report.sh
+11
-10
test.sh
test.sh
+19
-0
No files found.
5-generate-report.sh
View file @
21172507
#!/bin/bash
declare
-A
projects
#declare -A map
total
=
0
total
=
0
while
read
LINE
while
read
LINE
do
do
IFS
=
,
read
start end name email project country billFlag hours
<<<
"
$LINE
"
IFS
=
,
read
start end name email project country billFlag hours
<<<
"
$LINE
"
[[
$billFlag
==
"Y"
]]
&&
total
=
$((
$total
+
$hours
))
if
[[
$billFlag
==
"Y"
]]
;
then
echo
$project
$hours
projects[
$project
]=
$((
${
projects
[
$project
]
}
+
$hours
))
# map[$country]=$hours
total
=
$((
$total
+
$hours
))
fi
done
< ./timesheet.csv
done
< ./timesheet.csv
echo
Total:
$total
printf
"%-20s %6s
\n
"
"Project"
"Hours"
#for key in "${!map[@]}"; do echo $key; done
for
projectId
in
"
${
!projects[@]
}
"
do
printf
"%-20s %6s
\n
"
"
$projectId
"
"
${
projects
[
"
$projectId
"
]
}
"
done
printf
"%-20s %6s
\n
"
"Total"
"
$total
"
test.sh
0 → 100644
View file @
21172507
#!/bin/bash
declare
-A
projects
total
=
0
while
read
LINE
do
IFS
=
,
read
start end name email projectId country billFlag hours
<<<
"
$LINE
"
if
[[
$billFlag
==
"Y"
]]
;
then
projects[
$projectId
]=
$((
${
projects
[
$projectId
]
}
+
$hours
))
total
=
$((
$total
+
$hours
))
fi
done
< ./timesheet.csv
printf
"%-20s %6s
\n
"
"Project"
"Hours"
for
projectId
in
"
${
!projects[@]
}
"
do
printf
"%-20s %6s
\n
"
"
$projectId
"
"
${
projects
[
"
$projectId
"
]
}
"
done
printf
"%-20s %6s
\n
"
"Total"
"
$total
"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment