Browse Source

docs(better-cat): clarify usage

pull/1853/head
eslopfer 1 year ago
parent
commit
2e05b12caa
  1. 61
      subjects/devops/better-cat/README.md

61
subjects/devops/better-cat/README.md

@ -8,56 +8,35 @@ The script should accept any number of filenames as arguments, and it should pri
The script should also support the following options: The script should also support the following options:
- `-c`: If this option is provided, the script should exclude all lines that begin with the # character. - `-c`: If this option is provided, the script should exclude all lines that begin with the # character.
- `-l`: If this option is provided, the script should print the line number before each line of output. - `-l`: If this option is provided, the script should print the length of the line before each line of output.
- `-r`: If this option is provided, the script should print a summary line at the end of the output, indicating the total number of lines and characters printed. - `-r`: If this option is provided, the script should print a summary line at the end of the output, indicating the total number of lines in the file and the count of characters in the lines printed.
If both `-c` and `-l` are provided, the line number should include only non-comment lines.
### Usage ### Usage
```console ```console
$ bash better-cat.sh file1.txt $ echo "This is an example line of text." > example.txt
Here would be the content of file1 $ bash better-cat.sh example.txt
1: This is an example line of text.
$ bash better-cat.sh file1.txt file2.txt $ bash better-cat.sh file1.txt file2.txt
Here would be the content of file1 Here would be the content of file1
Here would be the content of file2 Here would be the content of file2
$ bash better-cat.sh $ bash better-cat.sh
Here would be the content of file1 Here would be the content of file1
Here would be the content of file2 Here would be the content of file2
Here would be the content of file3 Here would be the content of file3
$ echo "# This is a comment." > example.txt
$ bash better-cat.sh -c commented.txt $ echo "This is the second line of text." >> example.txt
Here would be line 1 of file3 $ bash better-cat.sh -c example.txt
Here would be line 2 of file3 2: This is the second line of text.
Here would be line 3 of file3 $ bash better-cat.sh -l example.txt
Here would be line 4 of file3 1 (20): # This is a comment.
Here would be line 5 of file3 2 (32): This is the second line of text.
Here would be line 6 of file3 $ bash better-cat.sh -r example.txt
Here would be line 7 of file3 1: # This is a comment.
Here would be line 8 of file3 2: This is the second line of text.
Here would be line 9 of file3 Total: 2 lines, 52 characters
Here would be line 10 of file3 $ bash better-cat.sh -cr example.txt
2: This is the second line of text.
$ bash better-cat.sh -l file1.txt Total: 2 lines, 32 characters
1: Here would be the content of file1
$ bash better-cat.sh -r file1.txt
Here would be the content of file1
Total: 1 lines, 35 characters
$ bash better-cat.sh -cl commented.txt
Here would be line 1 of file3
Here would be line 2 of file3
Here would be line 3 of file3
Here would be line 4 of file3
Here would be line 5 of file3
Here would be line 6 of file3
Here would be line 7 of file3
Here would be line 8 of file3
Here would be line 9 of file3
Here would be line 10 of file3
Total: 10 lines, 301 characters
``` ```

Loading…
Cancel
Save