Skip to content

nordinz7/py-cat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

py-cat

py-cat is a Python script that mimics the behavior of the Unix cat command with additional options for numbering lines.

Features

  • Read from multiple files or standard input.
  • Number all lines with the -n option.
  • Number non-blank lines with the -b option.

Usage

python main.py [options] [file ...]

Options

  • -n: Number all lines.
  • -b: Number non-blank lines.

Examples

Number all lines in a file

python main.py -n file.txt

Number non-blank lines in a file

python main.py -b file.txt

Read from standard input and number all lines

echo "Hello\nWorld" | python main.py -n

Read from multiple files

python main.py file1.txt file2.txt

Code Explanation

The script processes command-line arguments to determine the options and files to read. If no files are provided, it reads from standard input. It then processes the lines according to the specified options and prints them.

Argument Parsing

The parse_args function from utils.py is used to parse command-line arguments and set the appropriate options.

Line Processing

Lines are processed to add line numbers based on the specified options (-n for numbering all lines, -b for numbering non-blank lines).

Main Function

The main function reads from stdin if no files are provided, otherwise reads from the specified files and processes the lines accordingly.

License

This project is licensed under the MIT License.


Feel free to modify this README to better fit your project's needs.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages