|Subject:||Re: [PATCH] filter ls output by filetype|
|Date:||Fri, 29 Nov 2013 15:01:55 +1100|
On 11/28/2013 03:09 PM, Hal Ashburner wrote:
>If you're processing the output of ls then it's best
> On 29 November 2013 01:09, Pádraig Brady <address@hidden <mailto:address@hidden>> wrote:
> On 11/28/2013 01:49 PM, Hal Ashburner wrote:
to avoid the long listing and also handle symlinks like:
ls -ALF | sed -n 's#/$##p' | while read DIR; do echo process "$DIR"; done
However as a general rule ls is for human consumption,
and if you want to further process the output you'd
be better off starting with find(1), which is better
suited to filtering and generating output for further processing.
That might also help to handle non printable chars in a robust way:
find -L . -mindepth 1 -maxdepth 1 -type d -print0 |
while read -d $'\0' DIR; do echo process "[$DIR]"; done
Please continue to debate if you feel strongly.
> I think all of 1,2 and 3 are quite doable cleanly by filtering inside ls (which filters already so it's not a new task, just an extension and generalization of existing functionality). I'm in favor of the simplicity, discoverability and robustness of the interface that ls can provide. I don't think this is just any old junk, but something that is powerful and yet simple. I'd want to be thinking carefully about the appropriate switches to keep it as simple and robust as possible.
> Anyway, thanks for the review. Not going to touch it further if you're against it.
Open discussion is encouraged.
|[Prev in Thread]||Current Thread||[Next in Thread]|