-
Contributing Member
What is the command
What is the command that I can use in Linux to list the directory name alone. Could someone help me out in this?
-
Contributing Member
Re: What is the command
You can use the option –d or the directory command line option with the ls command. Suppose you want to list the directory names alone starting with a in directory /usr/x you can do that as follows:
ls –d /use/x/a*
-
Expert Member
Re: What is the command
In linux there is no direct way of listing directories,hence we combine the ls command with grep and type as follows:
1. use ls -l with grep
2. use find -type d
Example:
1.ls -l | grep "^d" -The simple way to list just directories, is using ls -l pipe with grep
2.find -L -maxdepth 1 -type d -name
here -L is to show also for the symbolic link to directory, -maxdepth limit the search up to only 1 level, -type d indicates that the file must be directory.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules