I want to see the recently used(accessed) files along with their path through terminal.

How could i get that files list?

Note: This question is not a duplicate of Show recent modified/created files using Terminal

  • Hey , so you mean like only the files used through terminal ? – rɑːdʒɑ May 21 '14 at 12:32
  • 1
    @raaz no, just view a file through nautilus and then run the command on my answer. It will display the recently accessed files along with it's path. – Avinash Raj May 21 '14 at 12:36

It works on Ubuntu systems which has nautilus as a default file-manager.

Run the below command on terminal to see the recently accessed(aka viewed) files.

sed -nr 's/.*href="([^"]*)".*/\1/p' ~/.local/share/recently-used.xbel

Information about all the recently accessed files are stored in this particular ~/.local/share/recently-used.xbel file. Extracting only the file along with it's path was done by the above command.

Command Explanation:

sed -nr 's/.*href="([^"]*)".*/\1/p' ~/.local/share/recently-used.xbel

-n --> suppress automatic printing of pattern space

-r --> Extended regex. If we use sed with -r, then we don't have to escape some characters like ((,),{,},etc)

's/.*href="([^"]*)".*/\1/p' --> sed searches for a line which has this(.*href="([^"]*)".*) regex in the input file. If it find any, then it grabs only the characters that are within double quotes which was after href=(href="") and stored it in a group. Only the stored group are printed through back-reference(\1).


$ sed -nr 's/.*href="([^"]*)".*/\1/p' ~/.local/share/recently-used.xbel

If you want the output to be formatted then run this,

$ sed -nr 's/.*href="([^"]*)".*/\1/p' ~/.local/share/recently-used.xbel | sed 's|\/\/| |g'
file: /media/truecrypt8/bar.txt
file: /media/truecrypt8/picture.txt
file: /media/truecrypt8/bob.txt
file: /media/truecrypt8/movie.txt
file: /media/truecrypt8/music.txt
file: /media/truecrypt8/foo.txt
  • 1
    Can you explain you command so we can understand ? – nux May 21 '14 at 12:37
  • this commands only works on Ubuntu ? – rɑːdʒɑ May 21 '14 at 12:41
  • @raaz It works on Ubuntu but i don't know about others. – Avinash Raj May 21 '14 at 15:59
  • Ok Friend, +1 for great work. Nice explanation indeed. – rɑːdʒɑ May 22 '14 at 5:15

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.