CLI byte

read log files in portions by bytes

You may want to read a log file for newly appended data. You could do it by knowing how many lines you read before and how many lines you have “now”. But when you have large log files, this approach will become very slow – try to run “wc -l” on file which has tens of millions of lines and you’ll see how slowly it counts. And you would have to do something like that each time you are reading new portion of data. What to do? Read log in bytes instead. Here is how.

Continue reading
grep man page

grep to output only needed capturing group

Say you have some text and some pattern that you want to provide for grep. Everything is easy, until you want to extract only the pattern-matching part, not the whole line that has the match. What to do?

You can “grep” and use pipe for further processing, like sed or awk. But did you know that you can do it solely with grep?

Continue reading