mdls返回`(null)`


2
function ls-by-added() {
    # Doesn't work well for files having '(null)' as their DateAdded, which some do.
    mdls -name kMDItemFSName -name kMDItemDateAdded -raw -- *(D) | \
        xargs -0 -I {} echo {} | \
        sed 'N;s/\n/ /' | \
        sort --reverse | \
        sed -E "s/^.*\\+0000 //" # removes the timestamps
}

它对dotfiles不起作用:

ls-by-added                                                                                      
foo
How Automated Recommendations Affect the Playlist Creation Behavior of Users_k2opt.pdf
research_report_dc_02_k2opt.pdf
research_report_dc_02.pdf
thebookofshaders_k2opt.pdf
thebookofshaders.pdf
A New Kind of Science
- Books alias
Hein J. L. - Prolog Experiments in Discrete Mathematics, Logic, and Computability (2005)_k2opt.pdf
Hein J. L. - Prolog Experiments in Discrete Mathematics, Logic, and Computability (2005).pdf
geMsearch- Personalized Explorative Music Search.pdf
Lumanote- A Real-Time Interactive Music Composition Assistant.pdf
How Automated Recommendations Affect the Playlist Creation Behavior of Users.pdf
Computability-and-Logic_k2opt.pdf
Computability-and-Logic.pdf
(null) .rm
(null) .foo
(null) .DS_Store

我究竟做错了什么?我mdimport .在运行命令之前尝试了工作目录,但它没有帮助。


你可以添加你的shell zsh到初始帖子。
fd0

@fsb问题是一样的bash
nohillside

为什么要用mdls于此(而不是ls -U)?无论如何,如果md没有信息,你可以做的就是添加grep -v '(null)到管道。
nohillside

@nohillside alias last-created='\ls -AtU|head -n1'。不是last-added:)
HappyFace
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.