Concept Flow - wc (word, line, character count)
Start: Provide file or input
wc reads input
Count lines, words, characters
Display counts
End
The wc command reads input, counts lines, words, and characters, then shows the results.
echo -e "Hello world\nThis is test" | wc| Step | Input Read | Lines Counted | Words Counted | Characters Counted | Output |
|---|---|---|---|---|---|
| 1 | "Hello world\nThis is test" | 2 | 5 | 24 | 2 5 24 |
| 2 | Output displayed | - | - | - | 2 5 24 |
| Variable | Start | After Input Read | Final |
|---|---|---|---|
| lines | 0 | 2 | 2 |
| words | 0 | 5 | 5 |
| characters | 0 | 24 | 24 |
wc command counts lines, words, and characters. Syntax: wc [options] [file] Default output: lines words characters Can read from files or pipes. Use -l for lines only, -w for words only, -c for characters only.