Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
spaces in filenames should be a crime.
- X-seq: zsh-users 22614
- From: Ray Andrews <rayandrews@xxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: spaces in filenames should be a crime.
- Date: Sun, 26 Mar 2017 13:22:24 -0700
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
Gentlemen:
This function:
mostrecent ()
{
ls -l ${(f)$( find . -type f -printf "%T@ %p\n" | sort -n | cut
-d' ' -f 2- | tail -n 1 )}
}
Testing it on this dummy directory tree:
├── [ 0] a
├── [4.0K] absolute junk
│ └── [ 0] junk
├── [ 0] b
└── [ 0] c
If the most recent file is under 'absolute junk', the function works,
but it requires the ' ${(f) ... ' treatment, otherwise it barfs at the
space in the directory name. However, if I change things to ' tail -n 3
" it shows me:
ls: cannot access './a ./absolute junk/junk ./c': No such file or directory
So whereas the ' ${(f) ' treatment fixes the one problem, it creates the
other, which is obviously that everything is one string. Can I have it
both ways? Protected spaces in the directory name, and still have
multiple items for the listing? I've done stuff like this before, but
using arrays. Or can printf handle the situation by itself?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author