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!!
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.....