Ubuntu – How to view recent files from the command-line

14.04command linefiles

Is it possible to view recently accessed files using a single command in the command-line?

Could you please provide an explanation of what exactly the command does?

Best Answer

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