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-26-2009 12:56 AM

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

ghostdog74 10-26-2009 01:14 AM

use find
Code:

find . -type d

pinga123 10-27-2009 12:14 AM

How do i list only hidden files.

bsat 10-27-2009 12:19 AM

list only directories using ls

ls -l | grep ^d

list only hidden files

ls -a | grep ^"\."

pinga123 10-27-2009 12:21 AM

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-27-2009 12:23 AM

How to find hidden files using find command.

ghostdog74 10-27-2009 12:23 AM

Code:

find . -type f -name ".*"

pinga123 10-27-2009 12:26 AM

can you please tell me the use of ^

pinga123 10-27-2009 12:28 AM

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-27-2009 12:50 AM

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 01: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 10:08 AM.