Hacker News new | past | comments | ask | show | jobs | submit login

What is wrong with:

  ls -l | grep '^d'



It is minimal, so does not meet the modern aesthetics of computer world.


Until you want something more specific like listing absolute paths of those directories without the metadata

ls -l | grep '^d' | awk '{print $9}' | xargs realpath

Or

ls -ld "$PWD"/* | grep '^d' | awk '{print $9}'

Guessing Crush could just add another property called Fullpath you can echo in the next pipe after filtering.

ls | where {type == "directory"} | select %Fullpath

Maybe he adds a --dir flag

ls --dir | select %Fullpath


% find . -maxdepth 1 -type d | xargs realpath

How long do these tools exist? Over 20 years?


The example works but you need to understand the idiosyncrasies of all the tools involved and the text format. Once you learn that you're passing around structured data and you access it the same way it becomes trivial get data.


Yes, you have to learn the idiosyncrasies of the tools involved. My point was, these are standard tools that are there for more than 20 years, and they work just fine. People should just RTFM and learn by experience instead of inventing something new which looks shiny on surface but most certainly will have unhandled hidden edge cases and serious limitations.


I've read most of the comments in this thread and will read TFA, but haven't yet.

What's always bothered me about piping to grep is losing the original syntax highlighting. Particularly annoying when the first command, whose highlighting I want to preserve, is itself grep; this leads to awkward contortions like

    git grep "a" | grep -v "b" | grep "a"


Outputs are not equivalent. But this will work:

    find . -type d




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: