![]() This example shows how to ignore the first N-1 lines and show only the remaining of the lines. $ tail -n 50 /var/log/messages Example 5: Ignore first N-1 lines of the file using tail command Change 50 to 100 to display the last 100 lines of the log file. This example displays only last 50 lines of /var/log/messages file. $ head -n -250 /var/log/secure Example 4: Display last N lines of the file using tail command The following example will display all the lines of the /var/log/secure except the last 250 lines. This example shows how to ignore the last N lines, and show only the remaining lines from the top of file. $ head -n 15 /var/log/maillog Example 3: Ignore last N lines of a file using head command Change 15 to 10 to display the first 10 lines of a log file. This example displays only first 15 lines of /var/log/maillog file. $ sed -n 101,110p /var/log/cron Example 2: Display first N lines of a file using head command In the following example, you can view the content of var/log/cron from line number 101 to 110. The example mentioned below will print the lines 120, 145, 1050 from the syslog. FILENAME : name of the file to be processed.sed : sed command, which will print all the lines by default.View only the specific lines mentioned by line numbers. In this article, let us review how to effectively view and manipulate huge log files using 10 awesome examples.Įxample 1: Display specific lines (based on line number) of a file using sed command Viewing huge log files for trouble shooting is a mundane routine tasks for sysadmins and programmers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |