How to view recent files from the command-line?

Solution 1:

My "recently" is 5 minutes =)

recently=5
find . -type f -amin "$recently"

Breakdown

  • find

    search for files in a directory hierarchy

  • .

    search in the current folder and all subfolders

  • -type f

    search only fort files

  • -amin 5

    File was last accessed 5 minutes ago.


Or perhaps you mean the recently used files in your Desktop Environment, than you need something like

awk -F"file://|\" " '/file:\/\// {print $2}' ~/.local/share/recently-used.xbel

Breakdown

  • awk

    pattern scanning and text processing language

  • -F"file://|\" "

    define two field separators, file:// and "

  • /file:\/\//

    only lines with file:// are interesting

  • {print $2}

    the path is in column 2

Solution 2:

The term recently is relative, I am going to assume last 10 minutes as recent in my answer (change that to fit your need).

Using find:

find . -type f -amin -10 

Here the -amin -10 would find all files (-type f) in the current directory and all subdirectories accessed within last 10 minutes.

For files accessed less than 30 minutes ago:

find . -type f -amin -30

Using zsh:

print -l **/*(.am-10)

**/* looks recursively for files and the glob qualifier (.am-10) finds files (.) accessed within the last 10 minutes (am-10).