I'm looking for a little shell script that will take anything piped into it, and dump it to a file.. for email debugging purposes. Any ideas?
the shortcut is Ctrl + Shift + S ; it allows the output to be saved as a text file, or as HTML including colors!
You can make it do so by using the pipe character '|'. Pipe is used to combine two or more commands, and in this, the output of one command acts as input to another command, and this command's output may act as input to the next command and so on.
To redirect input from a file, use the less-than symbol (<). The example here uses the sort command which simply sorts the input in order. The shell reads the contents of the required_packages. txt file into the standard input of the sort command which then orders the text and displays it on standard output.
The pipe character | is used to connect the output from one command to the input of another. > is used to redirect standard output to a file.
The unix command tee does this.
man tee
cat > FILENAME
You're not alone in needing something similar... in fact, someone wanted that functionality decades ago and developed tee :-)
Of course, you can redirect stdout directly to a file in any shell using the > character:
echo "hello, world!" > the-file.txt
The standard unix tool tee can do this. It copies input to output, while also logging it to a file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With