Songbird, 29 mars 2021, 00:55 de songb...@anthive.com:
> if you are going to do something to the contents of > a file you can use: > > $ grep "pattern" filename > output > > there are different versions of grep command (egrep and > fgrep too besides just grep - check the man pages). > > if you are taking the input to grep from some other > command you can pipe the output of that command to the > grep command and then redirect what comes out of that > into a file: > > $ command | grep pattern > outputfile > > less and more are what most would consider pager > programs and not really all that oriented towards > filtering like grep. > > for more complicated kinds of output processing > you can use awk/gawk or many other things available. > > i never much got into perl. > > i think more modern peoples use perl instead of > grep/awk/etc. :) > Actually, I asked this question because of my workflow here. First, I use the less pager to navigate quickly inside an input, not knowing beforehand what it looks like and what I will need to do. Then, I filter some lines depending on my own investigation. And finally, I'm thinking that it would be too bad to lose the remaining lines so I'm looking for a way to save them eventually. Of course, you're right, if I knew beforehand what to look for, there are more appropriate and advanced tools (even sed)! :) Best regards, l0f4r0