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 .
在运行命令之前尝试了工作目录,但它没有帮助。
@fsb问题是一样的
—
nohillside
bash
。
为什么要用
—
nohillside
mdls
于此(而不是ls -U
)?无论如何,如果md
没有信息,你可以做的就是添加grep -v '(null)
到管道。
@nohillside
—
HappyFace
alias last-created='\ls -AtU|head -n1'
。不是last-added
:)
zsh
到初始帖子。