4 ms·
What is wrong with: ls -l | grep '^d'
by betimsl 6y ago
What is wrong with:
ls -l | grep '^d'
- geodel 6y agoIt is minimal, so does not meet the modern aesthetics of computer world.
- Riverheart 6y agoUntil 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
- inshadows 6y ago% find . -maxdepth 1 -type d | xargs realpath How long do these tools exist? Over 20 years?
- Riverheart 6y agoThe 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.
- inshadows 6y agoYes, 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.
- smichel17 6y agoI'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"
- quesera 6y agoOutputs are not equivalent. But this will work: find . -type d