logo

utils-std

Collection of commonly available Unix tools

cmp.t (833B)


  1. #!/usr/bin/env cram
  2. # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. # SPDX-License-Identifier: MPL-2.0
  4. $ export PATH="$TESTDIR/../cmd:$PATH"
  5. $ test "$(command -v cmp)" = "$TESTDIR/../cmd/cmp"
  6. $ printf 'foo' > foo
  7. $ printf 'bar' > bar
  8. $ cmp foo foo
  9. $ cmp bar bar
  10. $ cmp foo bar
  11. foo bar differ: char 1, line 1
  12. [1]
  13. $ cmp -s foo bar
  14. [1]
  15. $ cmp bar foo
  16. bar foo differ: char 1, line 1
  17. [1]
  18. $ cmp -s bar foo
  19. [1]
  20. $ seq 1 3 > foo
  21. $ seq 1 2 > bar
  22. $ cmp foo bar
  23. cmp: EOF on bar line 3
  24. [1]
  25. $ cmp -s foo bar
  26. [1]
  27. $ echo '3 different' > bar
  28. $ cmp foo bar
  29. foo bar differ: char 1, line 1
  30. [1]
  31. $ cmp -s foo bar
  32. [1]
  33. $ seq 1 3 > foo
  34. $ seq 1 2 > bar
  35. $ cmp -l foo bar
  36. cmp: EOF on bar line 3
  37. [1]
  38. $ cmp -n 4 foo bar
  39. $ rm foo bar
  40. $ find .
  41. .