11

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?

2

2 Answers 2

11

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

1
  • 1
    He probably means ~/.local/share/recently-used.xbel
    – Rinzwind
    Nov 21, 2015 at 19:45
9

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .