gcat is a custom implementation of the cat tool in unix-based systems. This tool covers the basic functionality of the cat command. Basically, it concatenates the input file contents and prints to stdout. It also has the ability to read from stdin.
- first run
make build- this will produce an executable binary file named
gcat.
- this will produce an executable binary file named
gcatcan take upto two flags, these are-nto print line number in front of each line-bto print line number only in front of non blank lines-bhas more priority than-n
gcattakes filenames separated by commas- if a file path is not found, it throws a file not found error.
- a special filename is
-, which means take input from stdin.
./gcat test.txt- prints
test.txtfile content.
- prints
./gcat test.txt -n- prints
test.txtfile content with line number.
- prints
head -n1 test.txt | ./gcat -- prints input passed through the pipe from the previous command.
./gcat test.txt test2.txt- concatenates
test.txt&test2.txtfile contents and prints it.
- concatenates
sed G test.txt | ./gcat -n | head -n4sed Ginserts a blank line after each line intest.txt.- processes input passed through the pipe from the previous command and passes the output through a pipe.
head -n4prints first 4 lines from the pipe.
sed G test.txt | ./gcat -b | head -n5sed Ginserts a blank line after each line intest.txt.- processes input passed through the pipe from the previous command and passes the output through a pipe.
head -n5prints first 5 lines from the pipe.
- just run './install.sh' and it will automatically install the application.
- make sure, you have built the application
make buildbefore.