This question already has an answer here:
I have a log.txt file with various lines of strings and information.
I want to write a script to read the log.txt file line by line and any line that contains the word debug I want to put that line into a new file called debug.txt and all other lines should go to info.txt.
What is the best way to go about doing this? I tried to do a while loop but couldn't figure it out. Thanks
read
command reads its input data byte by byte. For further info, please see Why is using a shell loop to process text considered bad practice?, and the associated links. I was going to post an answer containing a short script using grep, and also mentioning that you can easily do it using awk, but Archemar has beaten me to it. :) – PM 2Ring Jul 7 at 3:56