How to save both matching and non-matching from grep
I use grep very often and am familiar with it's ability to return matching lines (by default) and non-matching lines (using the -v parameter). However, I want to be able to grep a file once to separate matching and non-matching lines. If this is not possible, please let me know. I realize I could do this easily in perl or awk, but am curious if it is possible with grep. Thanks! If it does NOT have to be grep - this is a single pass split based on a pattern -- pattern found > file1 pattern not found > file2 awk '/pattern/ {print $0 > "file1"; next}{print $0 > "file2"}' inputfile I had the exact