When I do ls -l | grep ^d
it lists only directories in the current directory.
What I'd like to know is what does the caret ^
in ^d
mean?
command linegrepspecial characters
When I do ls -l | grep ^d
it lists only directories in the current directory.
What I'd like to know is what does the caret ^
in ^d
mean?
Best Answer
Andy's answer is correct, as seen in the man page:
The reason it works is the
-l
flag tols
makes it use the long-listing format. The first thing shown in each line is the human-readable permissions for the file, and the first character of that is eitherd
for a directory or-
for a file