5

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?

4

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

  • He probably means ~/.local/share/recently-used.xbel – Rinzwind Nov 21 '15 at 19:45
4

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).

  • same comment: he probably means ~/.local/share/recently-used.xbel – Rinzwind Nov 21 '15 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.