LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 08-28-2006, 06:22 AM   #1
sgarci
LQ Newbie
 
Registered: Mar 2006
Posts: 25

Rep: Reputation: 15
grep command


Dear all,

I'd like to use the grep command to find all files and directories starting with the letter 'a' in the /etc directory.

What syntax do you use with the grep command?

Many thanks in advance.
 
Old 08-28-2006, 06:48 AM   #2
odcheck
Member
 
Registered: Aug 2006
Distribution: Fedora, CentOS, RHEL, Debian
Posts: 978

Rep: Reputation: 30
For this needs I won't use grep at all.
I would recommend ls a* or locate (1st you have to setup locate db using updatedb)
 
Old 08-28-2006, 06:48 AM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi,

Why use grep?

ls -d a*

If you are forced to use grep (wouldn't know why), you cannot do this only using grep:

This is one way: ls | grep "^a"

It's not clear if you want to do this recursive, if so then grep isn't the program to use. find would be a better option: find . -name "a*" -print

Hope this helps.
 
Old 08-28-2006, 07:13 AM   #4
sgarci
LQ Newbie
 
Registered: Mar 2006
Posts: 25

Original Poster
Rep: Reputation: 15
Thanks guys, the command ls | grep "^a" works brillianltly.
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to use grep command sharonyiisl Linux - Newbie 7 05-28-2006 03:46 PM
grep command itz2000 Linux - Newbie 2 09-21-2005 07:06 PM
grep command in c????? alnreddy Linux - Software 1 12-30-2004 01:01 AM
Help With GREP Command juliettree Linux - Newbie 3 04-08-2004 08:44 AM
grep command cuss Linux - General 7 02-14-2003 09:23 AM


All times are GMT -5. The time now is 11:25 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration