I meet some problem about "ls" this command
I want to print just only directory without hidden or linked
but I use man ls to look the explanation , but I didn't found
if there is a flag that I can do what I want ...
thanks
below is the question I am going to solve ...
4. Display the visible exits
This is two commands: The first command prints "Visible exits: "
-> It must not advance the cursor to the next line.
The second command displays the visible exits and then a period (.).
-> To prevent the linked directories contents from also displaying, you
will need a flag.
-> Several wildcard patterns will be needed.
-> The period will be the last of these patterns.
The period means the current directory. But here it will seem, to
the user, to be a period at the end of a sentence listing visible
exits.
-> You will need to use a flag to keep the output from being
sorted (otherwise the period will not stay at the end).
-> With several patterns to search, some may have no matches. That
is OK, but we don't want to see warning messages. Redirect these.
Use ls -d */
. The */
is a wildcard that expands to all directories in current directory (directories end in /
). -d
tells ls
to list the names of directories given as arguments and not their content.
You should look into the stat
command. Something like:
stat -c '%F %n' * | sed -n '/^directory /s///p'
There's also find
find . -maxdepth 1 -type d -print
Find will show you hidden directories (including .
the current directory)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With