-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcondense_profile
More file actions
executable file
·59 lines (56 loc) · 2.08 KB
/
condense_profile
File metadata and controls
executable file
·59 lines (56 loc) · 2.08 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
59
#!/bin/bash
if [ "$1" = '--help' ]; then
exit 1
elif [ "$1" = '--version' ]; then
exit 1
fi
declare -r matcherBase='/app/'
declare matcher='^ [0-9]\.[0-9]{2} ([^0]|0\.[^0]|0\.0[^0]|0\.00[^0123])|'
declare FILE=''
declare NEW_FILE='condensed'
shopt -s globasciiranges extglob
if [ "$1" = '--max' ]; then matcher=''; NEW_FILE+='-max'; shift; fi
if [ -e "$1" ]; then
declare -r FILE="$1"; shift
else
exit 1
fi
if [ "$1" = '--max' ]; then matcher=''; NEW_FILE+='-max'; shift; fi
if [ -e "$1" ]; then
declare -r NEW_FILE="$1"; shift
if [ "$1" = '--max' ]; then matcher=''; shift; fi
elif [ -n "$1" ]; then
NEW_FILE="$(get_command_path -d "$FILE")/$1"; shift
if [ "$1" = '--max' ]; then matcher=''; shift; fi
else
echo "$NEW_FILE"
NEW_FILE="$(get_command_path -d "$FILE")/$NEW_FILE"; shift
echo "$NEW_FILE"
if [ "$1" = '--max' ]; then matcher=''; NEW_FILE+='-max'; shift; fi
echo "$NEW_FILE"
fi
matcher+="$matcherBase"
declare -r matcher
NEW_FILE+='.txt'
declare -r NEW_FILE
IFS=$'\n'
mapfile -n 7 < <(cat "$FILE")
echo -n "${MAPFILE[@]}" >> "$NEW_FILE"
# grep -E -e '^ [0-9]\.[0-9]{2} ([^0]|0\.[^0]|0\.0[^0]|0\.00[^0])|/app/' "$FILE" >> "$NEW_FILE"
# grep -E -e '^ [0-9]\.[0-9]{2} ([^0]|0\.[^0]|0\.0[^0]|0\.00[^0123])|/app/' "$FILE" | sed -E 's/^(.{12})(.+)$/\2\1/' | sort -r --numeric-sort - | sed -E 's/^(.+)(.{12})$/\2\1/' >> "$NEW_FILE"
grep -E -e "$matcher" "$FILE" | sed -E 's/^(.{12})(.+)$/\2\1/' | sort -r --numeric-sort - | sed -E 's/^(.+)(.{12})$/\2\1/' >> "$NEW_FILE"
# mapfile lines < <(grep -E -e '^ [0-9]\.[0-9]{2} ([^0]|0\.[^0]|0\.0[^0]|0\.00[^0])|/app/' "$FILE" | sed -E 's/^(.{12})(.+)$/\2\1/' | sort --numeric-sort - | sed -E 's/^(.+)(.{12})$/\2\1/')
# declare -r matcher='^ [[:digit:]]\.[[:digit:]]{2} ([[:digit:].]+)'
# declare -A order=()
# for ((i = 0; i < ${#lines[@]}; i++)); do
# if [[ "${lines[$i]}" =~ $matcher ]]; then
# if decimal_compare "${BASH_REMATCH[1]}" '>' "$priorMax" && ((i > 0)); then
# for ((j = 0; j < ${#lines[@]}; j++)); do
# command ...
# done
# fi
# else
# echo "Couldn't match '${lines[$i]}'"
# fi
# done
#cat "$NEW_FILE"