Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

WC Utility

Overview

The wc utility is a Python3 implementation that mimics the Unix wc command. It counts newlines, words, characters, and bytes in files and standard input, providing users with essential text processing capabilities.

Requirements

  • Python 3.x

Usage Syntax

python wc.py [options] [file ...]

Options

  • -l : Count lines
  • -w : Count words
  • -c : Count bytes
  • -m : Count characters

Examples

File Input

python wc.py -l test.txt   # Count lines in test.txt
python wc.py -w test.txt   # Count words in test.txt
python wc.py -c test.txt   # Count bytes in test.txt

Stdin Piping

echo "Hello World" | python wc.py -w   # Count words from stdin
cat test.txt | python wc.py -l   # Count lines from stdin

Output Format

The default output format is tab-separated values showing counts for lines, words, characters, and bytes.

Notes / Limitations

  • The line count uses len(line) on bytes lines.
  • Word counting uses split to determine word boundaries.
  • When using stdin mode with no arguments, the utility will print 'not enough args'.

Included Test Data

The repository includes test.txt as a sample file to test the utility's features.

About

Follows being able to use utility with stdinf or file

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages