-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathawk.sh
More file actions
executable file
Β·58 lines (53 loc) Β· 2.66 KB
/
awk.sh
File metadata and controls
executable file
Β·58 lines (53 loc) Β· 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/awk -f
BEGIN {
FS = "|"
max_duration = 0
}
# Skip empty lines, comments, and system lines
/^#/ || /^[ \t]*$/ || /SYSTEM:/ || /CONFIG:/ || /CHECKSUM:/ {
next
}
# Process valid data lines
NF == 8 {
# Trim whitespace from fields
for (i = 1; i <= NF; i++) {
gsub(/^[ \t]+|[ \t]+$/, "", $i)
}
# Check if it's a completed Mars mission
if (tolower($3) == "mars" && tolower($4) == "completed") {
# Extract duration (field 6) and convert to number
duration = $6 + 0
# Check if duration is a valid number and is the longest so far
if (duration ~ /^[0-9]+$/ && duration > max_duration) {
max_duration = duration
date = $1
mission_id = $2
destination = $3
status = $4
crew_size = $5
success_rate = $7
security_code = $8
}
}
}
END {
if (max_duration > 0) {
print "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
print "β LONGEST SUCCESSFUL MARS MISSION FOUND β"
print "β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£"
printf "β Date: %-45s β\n", date
printf "β Mission ID: %-45s β\n", mission_id
printf "β Destination: %-45s β\n", destination
printf "β Status: %-45s β\n", status
printf "β Crew Size: %-45s β\n", crew_size
printf "β Duration: %-45s β\n", max_duration " days"
printf "β Success Rate: %-45s β\n", success_rate "%"
print "β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£"
printf "β SECURITY CODE: %-45s β\n", security_code
print "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
print ""
print "Answer: " security_code
} else {
print "No completed Mars missions found in the log file."
}
}