如何通过终端找到最近使用的文件?

我想看看最近使用过的(访问过的)文件以及它们通过终端的路径。

我怎么能得到那个文件列表?

注意:此问题与使用终端显示最近修改/创建的文件不重复

它适用于将nautilus作为默认文件管理器的Ubuntu系统。

在终端上运行以下命令以查看最近访问的(也称为已查看)文件。

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

有关所有最近访问的文件的信息存储在此特定的~/.local/share/recently-used.xbel文件中。 通过上述命令仅提取文件及其路径。

命令说明:

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

-n – >抑制模式空间的自动打印

-r – >扩展正则表达式。 如果我们使用sed和-r ,那么我们就不必转义一些字符,如( (){}等)

's/.*href="([^"]*)".*/\1/p' – > sed搜索具有此字符的行( .*href="([^"]*)".* )输入文件中的正则表达式。 如果找到任何,则它只抓取双引号内的字符,这些字符在href=href="" )之后并存储在一个组中。 仅通过反向引用( \1 )打印存储的组。

例:

 $ sed -nr 's/.*href="([^"]*)".*/\1/p' ~/.local/share/recently-used.xbel 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 

如果要格式化输出,请运行此,

 $ 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