LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-11-2008, 06:46 AM   #1
hiteshthappa
LQ Newbie
 
Registered: Jul 2008
Posts: 12

Rep: Reputation: 0
using grep command


HI
can anyone plz tell me how do i displayout the list of directories from my current working directory using grep command.
 
Old 07-11-2008, 07:21 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Welcome to LQ---Looking at both of your posts, it looks like you are asking homework questions. You need to be aware of the policies on this.

One way to do this is use the "ls -l" command and then use grep to find the leading "d" on all the directories.

Look at:
man ls
man grep
 
Old 07-11-2008, 07:27 AM   #3
mrrangerman
Member
 
Registered: Oct 2007
Location: MI
Distribution: Debian Slackware
Posts: 528

Rep: Reputation: 59
If your just looking to list the directories use ls to see all directories even hidden ls -a.
To learn more about grep man grep

Use grep with pipe

ls | grep argument
 
Old 07-11-2008, 07:28 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
You can also try
Code:
ls -d */
this will list only the directories, without listing the content of the directories themselves.
 
Old 07-11-2008, 08:34 AM   #5
aldomenico
LQ Newbie
 
Registered: May 2008
Posts: 3

Rep: Reputation: 0
To list all directories including the hidden ones:

ls -al | grep "^d"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me in Grep Command + cd command in single line JeiPrakash Linux - Newbie 3 05-27-2008 04:16 AM
grep command sgarci Linux - General 3 08-28-2006 07:13 AM
how to use grep command sharonyiisl Linux - Newbie 7 05-28-2006 03:46 PM
grep command in c????? alnreddy Linux - Software 1 12-30-2004 01:01 AM
grep command cuss Linux - General 7 02-14-2003 09:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration