I am looking to write a script to count the number of a term and its opposite and create a new file with said list. I can get the terms to print to the file but only one or the other and not both.
I tried this:
Good that you have shown us what you have tried to solve your own problem, keep it up.
Could you please do let us know sample of Input_file and expected output in CODE TAGS too it will make question more clearer.
With grep and friends you'll get one count per run, so you'll have to go through the file twice. Might not be a problem with small files, but resource consumption increases with sizes. Taylor your solution with a little script like e.g.
awk -v"PAT=done" '$0 ~ PAT {PRES++; next} {ABS++} END {print PRES ORS ABS}' file
What would you expect? The first grep s the lines with "done" in them and pipes it --- into nowhere! As the second opens the input file again to read from it and discards its stdin. You've been given examples of how to do it correctly.
Your desired output isn't too clear, at least to me.