Skip to content

Barcelona|oct2025-2|Zhenishai Zhanybek|ModuleTools|Sprint4 - #7

Open
Jenishai5 wants to merge 7 commits into
mainfrom
implementST
Open

Barcelona|oct2025-2|Zhenishai Zhanybek|ModuleTools|Sprint4#7
Jenishai5 wants to merge 7 commits into
mainfrom
implementST

Conversation

@Jenishai5

Copy link
Copy Markdown
Owner

Implement CLI tools: cat, ls, and wc

This PR introduces Python implementations of three classic Unix command-line tools: cat, ls, and wc. The goal was to replicate core functionality and behavior for specific use cases, following the project requirements.

Features
cat
Read and print file contents
Support multiple files and wildcard patterns (.txt)
-n flag: number all lines
-b flag: number only non-empty lines
Graceful handling of missing files
ls
List directory contents
-1 flag: display one item per line
-a flag: include hidden files
Support optional directory argument (defaults to current directory)
Sorted output for consistency
wc
Count lines, words, and characters
Support multiple files and wildcard patterns
Flags:
-l: lines only
-w: words only
-c: characters only
Displays totals when multiple files are provided
Implementation details
Used argparse for CLI argument parsing
Used glob to handle wildcard file patterns
Used os module for filesystem operations
Error handling implemented for missing files/directories
Output formatting aligned with expected Unix behavior
Tested commands
cat sample-files/1.txt
cat -n sample-files/
.txt
cat -b sample-files/3.txt

ls -1
ls -1 sample-files
ls -1 -a sample-files

wc sample-files/*
wc -l sample-files/3.txt
wc -w sample-files/3.txt
wc -c sample-files/3.txt
wc -l sample-files/*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant