zsh-users
 help / color / mirror / code / Atom feed
* spaces in filenames should be a crime.
@ 2017-03-26 20:22 Ray Andrews
  2017-03-26 20:57 ` Vadim A. Misbakh-Soloviov
                   ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Ray Andrews @ 2017-03-26 20:22 UTC (permalink / raw)
  To: Zsh Users

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?


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2017-03-30 17:36 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-26 20:22 spaces in filenames should be a crime Ray Andrews
2017-03-26 20:57 ` Vadim A. Misbakh-Soloviov
2017-03-26 21:18 ` Daniel Shahaf
2017-03-26 22:41   ` Ray Andrews
2017-03-26 23:20     ` Bart Schaefer
2017-03-27  0:47       ` Ray Andrews
2017-03-27  1:11         ` Chris ccb
2017-03-27  1:45           ` Ray Andrews
2017-03-27  1:44     ` Martijn Dekker
2017-03-27  2:17       ` Ray Andrews
2017-03-27 18:53         ` Jesper Nygårds
2017-03-27 23:18           ` Mikael Magnusson
2017-03-28  0:46             ` Ray Andrews
2017-03-28  9:08               ` Martin Richter
2017-03-28 14:29                 ` Ray Andrews
2017-03-28 16:10                   ` Daniel Shahaf
2017-03-28 18:01                     ` Ray Andrews
2017-03-28 18:38                   ` Martijn Dekker
     [not found]               ` <60a213ad-6cb3-bef4-9e61-f2c1611a5e71__30788.3357666016$1490694707$gmane$org@gmx.de>
2017-03-29 11:27                 ` Stephane Chazelas
2017-03-29 14:50                   ` Ray Andrews
2017-03-29 15:21                     ` Peter Stephenson
2017-03-29 16:21                       ` Ray Andrews
2017-03-30 17:36                         ` Bart Schaefer
2017-03-28 16:42           ` Matthew Martin
2017-03-26 21:24 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).