sort-entries 871 B

1234567891011121314151617181920212223
  1. #!/bin/bash
  2. # TODO: the best sorting results are acheived when the field separator
  3. # precedes any valid package name character in ASCII order -
  4. # the lowest of which is ASCII 43 '+'; so
  5. # ASCII 33 ('!') serves this purpose quite well -
  6. # someday, we should re-write the tools to use '!' instead of ':' -
  7. # then the sort command alone would yeild the same results as this script
  8. # and the warning could be removed from 'check.sh'
  9. readonly CSV_CHAR=':'
  10. readonly SEP_CHAR='!'
  11. for blacklist in *.txt
  12. do if grep ${SEP_CHAR} ${blacklist}
  13. then echo "can not sort: '${blacklist}' - contains '${SEP_CHAR}' char"
  14. else echo "sorting: '${blacklist}'"
  15. cat ${blacklist} | tr "${CSV_CHAR}" "${SEP_CHAR}" | sort | uniq | tr "${SEP_CHAR}" "${CSV_CHAR}" > ${blacklist}.temp
  16. mv ${blacklist}.temp ${blacklist}
  17. fi
  18. done