wc -c: Count Bytes (File Size)
wc -c counts bytes, so for a file it reports the size in bytes.
wc -c gives you a byte count from a stream or file, useful for size assertions and budget checks in pipelines.
What it does
wc -c counts the bytes in the input. For a regular file this equals its size on disk in bytes. It differs from -m, which counts characters: in a UTF-8 locale a multibyte character is several bytes (-c) but one character (-m).
Common usage
wc -c < artifact.tar.gz # size in bytes, number only
curl -s "$URL" | wc -c # response body size
[ "$(wc -c < file)" -lt 1000000 ] && echo "under 1MB"Options
| Flag | What it does |
|---|---|
| -c | Count bytes |
| -m | Count characters (locale-dependent) |
| -l / -w | Count lines / words |
In CI
Use wc -c < file to assert an artifact is non-empty or under a size budget; the redirect form returns a bare number suitable for arithmetic comparison. For a stream, wc -c counts everything that flows through it.
Common errors in CI
wc -c is bytes, not characters; do not use it to count UTF-8 characters where -m is correct. The wc -c file form prints the filename alongside the number and breaks numeric tests; redirect with < to get only the count. Counting a directory argument errors; pass files or a stream.