py-cat
is a Python script that mimics the behavior of the Unix cat
command with additional options for numbering lines.
- Read from multiple files or standard input.
- Number all lines with the
-n
option. - Number non-blank lines with the
-b
option.
python main.py [options] [file ...]
-n
: Number all lines.-b
: Number non-blank lines.
python main.py -n file.txt
python main.py -b file.txt
echo "Hello\nWorld" | python main.py -n
python main.py file1.txt file2.txt
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.
The parse_args
function from utils.py
is used to parse command-line arguments and set the appropriate options.
Lines are processed to add line numbers based on the specified options (-n
for numbering all lines, -b
for numbering non-blank lines).
The main function reads from stdin if no files are provided, otherwise reads from the specified files and processes the lines accordingly.
This project is licensed under the MIT License.
Feel free to modify this README to better fit your project's needs.