Fall 2025 Edition
This project extends the FogOS/xv6 cat utility with several Linux-style options to demonstrate user-space programming, system-call–based file I/O, and command-line parsing. Implemented flags include -n (number all lines), -b (number nonempty lines), -E (show $ at end of each line), and -s (squeeze consecutive blank lines). The work preserves original cat behavior while adding composable formatting features.
-n— Number all output lines-b— Number nonempty output lines only-E— Display$at the end of each line-s— Squeeze multiple consecutive blank lines into a single blank line
Options can be combined.
Example:
cat -nEs file.txtFrom the project root directory, run:
make clean
make qemuInside the FogOS shell:
cat [options] [file...]
If no file is provided, cat reads from standard input.
Multiple options can be combined and multiple files can be listed.$ cat -n test.txt
1 hello
2 world
$ cat -bE test.txt
1 hello$
$
2 world$
$ echo -e "foo\nbar" | cat -nEs
1 foo$
2 bar$The following commands were verified inside QEMU:
cat -n test.txt # number all lines
cat -b test.txt # number nonempty lines only
cat -E test.txt # show $ at end of each line
cat -s test.txt # squeeze consecutive blank lines
cat -nEs test.txt # combine options
echo "abc" | cat -n # read from stdin
cat -n file1 file2 # multiple files
Edge Cases
Empty files
Files with only blank lines
Consecutive blank lines
Large files to confirm no performance regressionsuser/cat.c— Enhanced implementation of thecatcommandMakefile— UpdatedUPROGSlist to include the rebuiltcat
- Code follows xv6/FogOS formatting standards (2-space indentation, minimal library usage).
- Performance is equivalent to the original
cat(no regressions). - This README provides all required documentation for building, running, and testing the software.
