Common Linux log files name and usage--reference
|
Example 6: View growing log file in real time using tail commandThis is probably one of the most used command by sysadmins.To view a growing log file and see only the newer contents use tail -f as shown below.The following example shows the content of the /var/log/syslog command in real-time.<div class="block-panel"> Example 7: Display specific lines (based on line number) of a file using head and tail commandThe example below will display line numbers 101 – 110 of /var/log/anaconda.log fileM – Starting line numberN – Ending line number<div class="block-panel"> cat : prints the whole file to the stdout.tail -n +101 : ignores lines upto the given line number,and then start printing lines after the given number.head -n 10 : prints the first 10 line,that is 101 to 110 and ignores the remaining lines.Example 8: Display lines matching a pattern,and few lines following the match.The following example displays the line that matches “Initializing CPU” from the /var/log/dmesg and 5 lines immediately after this match.<div class="block-panel"> [Note: The above shows the line and 5 lines after the pattern matching]Example 9: Displaying specific bytes from a file.The following example explains how to display either the top 40 or the last 30 bytes of a file.<div class="block-panel">Display first 40 bytes from syslog.$ head -c40 /var/log/syslog <div class="block-panel">Display last 30 bytes from syslog.$ tail -c30 /var/log/syslog (编辑:网站开发网_马鞍山站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |

