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 05-09-2006, 07:34 PM   #1
zendez33
LQ Newbie
 
Registered: May 2006
Posts: 3

Rep: Reputation: 0
egrep noobie


Im fairly new to linux but I have to write a bash script using egrep that searchs a directory and list the filenames. For example the directory rc0.d contains a bunch of scripts. Now I need to print all files in rc0.d that begin with K.
I have been stuck on this for awhile... thought this would do it

egrep -r 'K' rc0.d

but it dosnt...Can anyone lend me a hand here...Thank you!!
 
Old 05-09-2006, 09:00 PM   #2
JimBass
Senior Member
 
Registered: Oct 2003
Location: New York City
Distribution: Debian Sid 2.6.32
Posts: 2,100

Rep: Reputation: 49
First things first, read the rules:
http://www.linuxquestions.org/linux/rules.html

Of particular importance is the line, "Do not expect LQ members to do your homework - you will learn much more by doing it yourself."

Beyond that, egrep is a poor choice for that job. The problem with your script is that you did the equivalent in linux of asking your window$ box to search the symantec directory. You need to tell it specifics. c:\windows\program files\symantec might work, and you need to do that same thing in linux.

Peace,
JimBass
 
Old 05-09-2006, 09:09 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by zendez33
Im fairly new to linux but I have to write a bash script using egrep that searchs a directory and list the filenames. For example the directory rc0.d contains a bunch of scripts. Now I need to print all files in rc0.d that begin with K.
I have been stuck on this for awhile... thought this would do it

egrep -r 'K' rc0.d

but it dosnt...Can anyone lend me a hand here...Thank you!!
Homework??--not obvious

You cant' grep (egrep) on a directory--only a file (or the output of another command)

In the directory, the command "ls | grep K" will print all filenames beginning with K. This illustrates the pipe function---output of ls is piped to input of grep.

have you read the man page for grep (egrep)?


To the residents here: In my experience, we'll know this was homework if we never hear from him again.....
 
Old 05-09-2006, 10:26 PM   #4
zendez33
LQ Newbie
 
Registered: May 2006
Posts: 3

Original Poster
Rep: Reputation: 0
I am not asking anyone to do the assignment for me. I normally wouldnt ask for help but I was really stuck here. I was just looking for some tips, pointers anything...I also didnt know asking questions about an assignment was off limits, but now I know..So thanks guys from responding I really appreciate it....

Last edited by zendez33; 05-09-2006 at 10:35 PM.
 
Old 05-09-2006, 11:21 PM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by zendez33
I am not asking anyone to do the assignment for me. I normally wouldnt ask for help but I was really stuck here. I was just looking for some tips, pointers anything...I also didnt know asking questions about an assignment was off limits, but now I know..So thanks guys from responding I really appreciate it....
Personally, I think the rules on getting help with homework are fairly loose. In this case, you asked a very focussed question after already trying. What ticks me off is the student who simply cut and paste from the assignment. They typically get NO help.
 
Old 05-10-2006, 12:59 AM   #6
zendez33
LQ Newbie
 
Registered: May 2006
Posts: 3

Original Poster
Rep: Reputation: 0
Yea i totally understand. I dont wanna get off on a bad leg here. Im just new to this and everything. Like I said I usually dont ask for help I sit and rack my brain till i firgue it out...plus I just setup linux on one of my other pcs so I imagine ill need the help of this forum in the near future....thanx
 
  


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
Parsing out html with egrep binaryechoes Linux - Newbie 3 12-02-2005 01:41 AM
egrep question internal_war Linux - Newbie 6 05-05-2005 07:32 PM
Help with egrep smart_sagittari Linux - Newbie 2 05-02-2005 09:18 AM
Using Grep and Egrep linux-nerd Linux - General 5 10-10-2004 12:37 PM
Using egrep Barbarian Programming 5 10-20-2002 03:54 PM


All times are GMT -5. The time now is 04:34 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration