1 unstable release
0.1.0 | Nov 12, 2023 |
---|
#56 in #educational
15KB
220 lines
* * * * Usage * * * *
Generate a file named, myfile with 128kbps of random data.
dd if=/dev/urandom bs=1024 count=128 of=myfile
Preview file info
ls -lh
Build a binary
cargo build
Cat the file then pipe the bytes to pipe-viewer
cat myfile | target/release/pipeviewer > myfile2
Using the 'yes' utility to test broken pipe error handling
yes | cargo run | head -n 1 > /dev/null
Preview console output
yes | cargo run | head -n 100000000 > /dev/null
Running the binary with cargo run
cargo run -- -h
Testing commandline arguments
cargo run -- somefile --outfile file.out -s
Testing environment variable with command line arguments
PV_SILENT=1 cargo run -- somefile --outfile file.out -s
Testing reader and writer
echo "some input" | cargo run --
Reroute output to /dev/null
echo "some input" | cargo run -- > /dev/null
Reroute output to outfile, -o /dev/null
echo "some input" | cargo run -- -o /dev/null
Generate output to outfile, -o output.txt
echo "some input" | cargo run -- -o output.txt
Reading from a file, output.txt -o /dev/null
echo "some input" | cargo run -- output.txt -o /dev/null
Reading from a file, output.txt -o /dev/null in silent
echo "some input" | cargo run -- output.txt --silent / -s
Write to a file with batch input
yes | cargo run -- -o yes.txt
Read from large input file
cargo run -- yes.txt -o /dev/null
Testing BufReader & BufWriter
cargo run -- yes.txt -o yes2.txt
Read from file and redirect output to specified output file
cargo run -- yes2.txt -- > yes3.txt
Piping output to head and redirect output to /dev/null
yes | cargo run -- | head -n 100000000 > /dev/null
Dependencies
~4MB
~64K SLoC