How to search for old files in Linux? [closed]

1

I need to use the tail -f command to search past logs . I know there are tail -f | grep "" .

But I do not know how to look for the old ones with the parameter I want. Can anyone help me?

    
asked by anonymous 13.02.2015 / 18:31

2 answers

1

To search for files that have a certain age, you can use grep in conjunction with find through the -mtime option to perform the search.

The example below will look for the word foo in all files modified up to 20 days ago in the current directory.

find . -type f -mtime -20 -print0 | xargs -0 grep -li 'foo'

To search for modified files there is n minutes ago use -mmin instead of -mtime .

    
13.02.2015 / 19:59
0

I do not know if I understood the question well. Do you need to fetch something from old logs?

If this is the case, you should not need tail -f, it is only useful for tracking logs that are currently running (for example, you need to see some exceptions while browsing your site).

For old files (which are no longer changed), only grep should work.

Going in the log directory you can run

grep -i 'oquevoceprocura' *

(the -i is not to differentiate between lower case capitals)

This will fetch this string from all files in the current directory.

More about grep:

link

link

    
13.02.2015 / 19:15