How to view a linux file?

How to view multiple log files as one file in unix/linux

  • I was wondering if there is a convenient way in linux/unix to read multiple log files as one. More specifically, I would like to view a sequence of log files (app.log, app.log.1 app.log.2, etc) as one big file using normal unix tools (vi, less, etc). When the EOF is read the tool will automatically move to the beginning of the next file. During my work I have to analyze uat/prod logs to investigate and solve problems. The fact that I need to traverse many log files disturbs my work and causes delays. Any ideas?

  • Answer:

    You can use lists of files and file globbing to specify multiple files. One big file: cat file1 file2 anotherbunch* log[a-z] | less A sequence of files (type :n to go to the next one): less -e file1 file2 anotherbunch* log[a-z] The -e switches to the next file automatically when the end of the current file is reached (twice) and exits when the end of the last file is reached (twice). To do that on the first time EOF is reached, use the -E option.

Kostas at Server Fault Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.