Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

spaces in filenames should be a crime.



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