How to display certain lines from a text file in Linux?

sed -n ‘10000000,10000020p’ filename You might be able to speed that up a little like this: sed -n ‘10000000,10000020p; 10000021q’ filename In those commands, the option -n causes sed to “suppress automatic printing of pattern space”. The p command “print[s] the current pattern space” and the q command “Immediately quit[s] the sed script without processing … Read more

How can I tail a log file in Python?

So, this is coming quite late, but I ran into the same problem again, and there’s a much better solution now. Just use pygtail: Pygtail reads log file lines that have not been read. It will even handle log files that have been rotated. Based on logcheck’s logtail2 (http://logcheck.org)

Printing the last column of a line in a file

You don’t see anything, because of buffering. The output is shown, when there are enough lines or end of file is reached. tail -f means wait for more input, but there are no more lines in file and so the pipe to grep is never closed. If you omit -f from tail the output is shown immediately: @EdMorton is right of course. Awk can search for A1 as well, … Read more