抱歉,这个问题对于新手来说太难了。如何使用locate命令在特定目录中进行搜索?
以下命令对我来说不起作用:
# locate -i mnt/external/Songs/"tangerine"
我想在“歌曲”文件夹中搜索。
答案1
也许你想要
locate -ir 'mnt/external/Songs/.*tangerine'
-r
用于正则表达式搜索,例如grep
。您还可以在如下简单情况下使用普通 glob:
locate /mnt/external/Songs/*tangerine*
答案2
尝试 find 命令
find /mnt/external/Songs/ -iname tangerine*
例子:我想搜索带有这个词的歌曲 协奏曲在他们的文件名中音乐文件夹,因此:
nits@nits-workstation:~$ find /mnt/Storage_1/Music/ -iname *concerto*
输出:
/mnt/Storage_1/Music/Music I/Antonio Vivaldi - The Four Seasons and Violin Concertos
/mnt/Storage_1/Music/Music I/Antonio Vivaldi - The Four Seasons and Violin Concertos/10. Concerto No. 4 In F Minor, Rv 297 'winter' - I Allegro Non Molto.mp3
/mnt/Storage_1/Music/Music I/Antonio Vivaldi - The Four Seasons and Violin Concertos/01. Concerto No. 1 In E, Rv 269 'spring' - I Allegro.mp3
这是该命令的一个很好的教程find
。