I was just wondering if it was at all possible when using different stream editing and text processing/manipulation tools; such as grep, cut, sed, awk, perl etc. Are there ways to output (in the form of a file or STDOUT) the inverse of the output (To put it another way, what ever was not extracted when running the command) in a universal way i.e. with another application, rather than using the tools features and optional flags to accomplish it.
So for example:
This would print lines in a file that match the regex:
sed '/regexp/!d
This would print lines in a file that do not match the regex:
sed '/regexp/d'
Is it possible to simply run only one of these commands and also have the data that is not contained STDOUT to be also outputted somewhere as well, without using sed's options, but rather a universal method that could then be applied to an awk or grep command.
Could you do something like this, using conn and output the sed command to a file and then compare the original file against the outputted file and output the difference. Something like (also I'm sure this that the syntax is incorrect but I hope the logic is attainable):
comm <(sort originalFile) <(sort sedProcessedFile) > originalFileMinussedProcessedFile
But not only apply this to sed but any sort of text/stream manipulation tool, or at least awk and perl.