summaryrefslogtreecommitdiff
path: root/sort-entries
blob: f6880296e84482a9092aaee7c0d640ed82cf8a42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash

# TODO: the best sorting results are acheived when the field separator
#       precedes any valid package name character in ASCII order -
#       the lowest of which is ASCII 43 '+'; so
#       ASCII 33 ('!') serves this purpose quite well -
#       someday, we should re-write the tools to use '!' instead of ':' -
#       then the sort command alone would yeild the same results as this script
#       and the warning could be removed from 'check.sh'

readonly CSV_CHAR=':'
readonly SEP_CHAR='!'


for blacklist in *.txt
do  if   grep ${SEP_CHAR} ${blacklist}
    then echo "can not sort: '${blacklist}' - contains '${SEP_CHAR}' char"
    else echo "sorting: '${blacklist}'"
         cat ${blacklist} | tr "${CSV_CHAR}" "${SEP_CHAR}" | sort | uniq | tr "${SEP_CHAR}" "${CSV_CHAR}" > ${blacklist}.temp
         mv ${blacklist}.temp ${blacklist}
    fi
done