2
I have a very long file containing file paths, one on each line. I would like to retrieve a list of all directories listed which are only 1-level deep. As such, I would like to extract only those lines which have a single /
in them:
I want: ./somedir
I don't want: ./somedir/someotherdir
Can I do this with grep and/or regular expressions?
1As an aside, the example you gave with the
./
leads me to believe you're generating a list with find. Assuming that's the case, you can do something like this:find . -maxdepth 1 (other conditions)
. – Brian Vandenberg – 2011-05-10T16:17:11.197