logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/

uniq.sh (866B)


  1. #!/bin/sh
  2. # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. # SPDX-License-Identifier: MPL-2.0
  4. WD="$(dirname "$0")"
  5. target="${WD}/../cmd/uniq"
  6. plans=7
  7. . "$(dirname "$0")/tap.sh"
  8. t --input='' noargs '' ''
  9. foo_nl='foo
  10. '
  11. t --input="$foo_nl" stdin '' "$foo_nl"
  12. t --input="$foo_nl" stdin_dash '-' "$foo_nl"
  13. t_ltrim() {
  14. "$target" "$@" | sed 's;[[:space:]]*;;'
  15. }
  16. t_cmd posix_cf1 \
  17. '1 #01 foo0 bar0 foo1 bar1
  18. 1 #02 bar0 foo1 bar1 foo1
  19. 1 #03 foo0 bar0 foo1 bar1
  20. 1 #04
  21. 2 #05 foo0 bar0 foo1 bar1
  22. 1 #07 bar0 foo1 bar1 foo0
  23. ' t_ltrim -c -f 1 "${WD}/uniq_0I.txt"
  24. t_args posix_df1 '#05 foo0 bar0 foo1 bar1
  25. ' -d -f 1 "${WD}/uniq_0I.txt"
  26. t_args posix_uf1 \
  27. '#01 foo0 bar0 foo1 bar1
  28. #02 bar0 foo1 bar1 foo1
  29. #03 foo0 bar0 foo1 bar1
  30. #04
  31. #07 bar0 foo1 bar1 foo0
  32. ' -u -f 1 "${WD}/uniq_0I.txt"
  33. t_args posix_ds2 '' -d -s 2 "${WD}/uniq_0I.txt"