wc.t (1686B)
- #!/usr/bin/env cram
- # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
- # SPDX-License-Identifier: MPL-2.0
- $ export PATH="$TESTDIR/../cmd:$PATH"
- $ test "$(command -v wc)" = "$TESTDIR/../cmd/wc"
- $ export LANG=C.UTF-8 LC_ALL=C.UTF-8
- $ printf 'a b c' | wc
- \s*0\s*3\s*5\s* (re)
- $ printf 'a\nb\nc\n' | wc
- \s*3\s*3\s*6\s* (re)
- $ printf 'a\nb\nc\n' | wc -clw
- \s*3\s*3\s*6\s* (re)
- $ printf 'a\nbb\nccc\n' | wc
- \s*3\s*3\s*9\s* (re)
- $ printf 'a\nbb\nccc\n' | wc -clw
- \s*3\s*3\s*9\s* (re)
- $ printf 'я нет 草' | wc -m
- \s*7\s* (re)
- $ printf 'я нет 草' | wc -mw
- \s*3\s*7\s* (re)
- $ printf 'я нет 草' | wc -mlw
- \s*0\s*3\s*7\s* (re)
- $ wc <&-
- wc: Failed reading from file '<stdin>': Bad file descriptor
- [1]
- $ wc -m <&-
- wc: Failed reading from file '<stdin>': Bad file descriptor
- [1]
- $ echo -n >empty
- $ wc empty
- 0 0 0 empty
- $ wc /var/empty/e/no/ent
- wc: Failed opening file '/var/empty/e/no/ent': No such file or directory
- [1]
- Formatting with reduced counts
- $ echo | wc -l
- 1
- $ echo a | wc -l
- 1
- $ echo | wc -c
- 1
- $ echo a | wc -c
- 2
- $ echo | wc -w
- 0
- $ echo a | wc -w
- 1
- $ echo | wc -cl
- 1 1
- $ echo a | wc -cl
- 1 2
- $ wc -c empty
- 0 empty
- $ wc -cl empty
- 0 0 empty
- $ wc -w empty
- 0 empty
- Total when multiple files are specified
- $ echo foo | wc empty -
- 0 0 0 empty
- 1 1 4
- 1 1 4 total
- $ printf 'foo bar\n' > foobar
- $ wc foobar empty
- 1 2 8 foobar
- 0 0 0 empty
- 1 2 8 total
- $ printf 'foot bart\n' > footbart
- $ wc -c foobar footbart empty
- 8 foobar
- 10 footbart
- 0 empty
- 18 total
- $ rm foobar footbart empty
- $ find .
- .