I have a text log of computation which contains a line for each iteration. We track the computation with
tail -f log.txt
But the lines of log file are very long and the tail output is unreadable.
I've tried this
tail -f log.txt | head -c 50
but it shows only beginning of the first line, but not lines which are produced after.
How can I dynamically display only first 50 characters of newly added line to the log file?
Thank you
The tail command is used to print last 10 lines of a file by default. However, like the head command, we can change the number number of lines to be displayed by using the -n option, or just -<number> , to display a different number of lines as specified.
where head -c5 is the right command to get the first 5 characters from the string. Save this answer. Show activity on this post. And how exactly does this print the first 5 chars of every line of sample.
The head command is used to display the first lines of a file. By default, the head command will print only the first 10 lines. The head command ships with the coreutils package, which might be already installed on our machine.
To look at the first few lines of a file, type head filename, where filename is the name of the file you want to look at, and then press <Enter>. By default, head shows you the first 10 lines of a file. You can change this by typing head -number filename, where number is the number of lines you want to see.
Use cut:
tail -f log.txt | cut -b 1-50
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With