Skip to content

West Midlands | 26 March SDC | Iswat Bello | Sprint 4 | implement shell tools in python#505

Open
Iswanna wants to merge 3 commits intoCodeYourFuture:mainfrom
Iswanna:tools/sprint4/implement-shell-tools-in-python
Open

West Midlands | 26 March SDC | Iswat Bello | Sprint 4 | implement shell tools in python#505
Iswanna wants to merge 3 commits intoCodeYourFuture:mainfrom
Iswanna:tools/sprint4/implement-shell-tools-in-python

Conversation

@Iswanna
Copy link
Copy Markdown

@Iswanna Iswanna commented Apr 19, 2026

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

In this PR, I implemented three core Unix shell utilities in Python: cat, ls, and wc.

cat/cat.py

  • Python implementation of file concatenation utility
  • -n/--number flag: number all output lines
  • -b/--number-nonblank flag: number only non-empty lines
  • Support single and multiple file arguments
  • Read files with UTF-8 encoding
  • Proper error handling with exit codes

ls/ls.py

  • Python implementation of directory listing
  • -1/--one-per-line flag: list one file per line
  • -a/--all flag: show hidden files (dotfiles)
  • Colour directories in blue using ANSI escape codes
  • Sort entries case-insensitively
  • Support custom directory path (default to current directory)
  • Proper error handling

wc/wc.py

  • Python implementation of word count utility
  • -l/--lines flag: print line counts
  • -w/--words flag: print word counts
  • -c/--bytes flag: print byte counts
  • Read from stdin when no files provided
  • Support multiple files with totals row
  • Byte counts calculated from raw file bytes for accuracy
  • Right-justified column formatting (4-char width)
  • Proper file not found error handling

Iswanna added 3 commits April 11, 2026 16:12
- Add .venv to ignore Python virtual environments
- Add *.class to ignore Java compiled class files
- Implement ls/ls.py: Python version of ls utility
- Add -1/--one-per-line flag for single column output
- Add -a/--all flag to show hidden files (dotfiles)
- Color directories in blue using ANSI escape codes
- Sort entries case-insensitively for better readability
- Support custom directory path argument (default to current directory)
- Add error handling with proper exit codes
- Match behavior of JavaScript implementation
- Implement wc/wc.py: Python version of wc utility
- Support -l/--lines, -w/--words, -c/--bytes flags
- Read from stdin when no files provided
- Process multiple files with totals row
- Calculate byte counts using raw file bytes for accuracy
- Format output with right-justified columns (4-char width)
- Handle file not found errors with proper exit codes
- Match behavior of JavaScript implementation
- Add argparse for robust CLI argument parsing
@Iswanna Iswanna added 📅 Sprint 4 Assigned during Sprint 4 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Tools The name of the module. labels Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Tools The name of the module. Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 📅 Sprint 4 Assigned during Sprint 4 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant