LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to list directories only (http://www.linuxquestions.org/questions/linux-newbie-8/how-to-list-directories-only-764450/)

pinga123 10-25-2009 11:56 PM

How to list directories only
 
Hi guys how can i list only directories using ls

ghostdog74 10-26-2009 12:14 AM

use find
Code:

find . -type d

pinga123 10-26-2009 11:14 PM

How do i list only hidden files.

bsat 10-26-2009 11:19 PM

list only directories using ls

ls -l | grep ^d

list only hidden files

ls -a | grep ^"\."

pinga123 10-26-2009 11:21 PM

Quote:

Originally Posted by bsat (Post 3733647)
list only directories using ls

ls -l | grep ^d


list only hidden files

ls -a | grep ^"\."

can you please tell me the use of ^

pinga123 10-26-2009 11:23 PM

How to find hidden files using find command.

ghostdog74 10-26-2009 11:23 PM

Code:

find . -type f -name ".*"

pinga123 10-26-2009 11:26 PM

can you please tell me the use of ^

pinga123 10-26-2009 11:28 PM

Quote:

Originally Posted by ghostdog74 (Post 3733654)
Code:

find . -type f -name ".*"

Please find the output of both command i thing ls -a | grep ^"\." is more accurate as it has listed . and .. correctly where as find . -type f -name ".*" only displayed profile hidden file which i think is not the only hidden file .
I m a newbie in unix can you please correct me if i m wrong?
[root@test milind]# ls -a | grep ^"\."
.
..
.profile
[root@test milind]# find . -type f -name ".*"
./.profile

etech3 10-26-2009 11:50 PM

Quote:

Originally Posted by pinga123 (Post 3733649)
can you please tell me the use of ^

That is the control key on your keyboard

snowtigger 10-27-2009 12:00 AM

Regular expression metacharacters

^ = Start of line

so "ls -l | grep ^d" will grep each line of output from ls for lines that begin with d and only d. (it will ignore d in any other position of the line).

:)


All times are GMT -5. The time now is 05:36 AM.