On Tue, Mar 14, 2000 at 01:44:15AM -0500, Karthik Vishwanath wrote:
> What is the difference between
> ls -lF | grep -e d* and
> grep -e d* | ls -lF ?
ls -lF | grep -e d*
this means run the command ls -lF[1] and then take anything that
comes out of standard out[2] and feed it into standard in[2] of grep -e d*
which does different things based on the directory that you are in.
Because you have typed d* instead of "d*" 'd*' or d\* [3]. The shell
expands the * .
1.
If you are in a directory with no files that begin with 'd',
then. csh and tcsh will expand the * to match the null string
and complain to the screen 'grep: No match.' bash and ksh will
not expand the * and will pass it to grep. grep will then look
at d* interperet it by he rules of regular expressions[4].
d* means to match any line that has 0 or more d's( every line i've
ever seen :-) ), so grep will end up matching everything and the
output of ls -lF will come out to the original standard out.
2.
If you are in a directory with one file starting with d, grep
will show all lines from ls -lF that contain the name of that
file[5].
3.
If you are in a directory with multiple files, grep will take
the name of the first file beginning with d and look for that
name in all of the other files that begin with 'd'.
grep -e d* | ls -lF
lists all files in the current directory in long format[6], with indicators
of filename appended[1]. The grep command does nothing important, except that
if d* expands to nothing, you will see an error message before the directory
listing, either from your shell or grep.
>
> Where can I find docs on things such as these?
>
[1] man ls
[2] man stdin/stdout/stderr ( not real good but I can't find anything better )
[3] man csh, tcsh, zshexpn, bash, ksh
[4] man 7 regex
[5] man grep && [p]info grep
> Thanks,
> -Karthik.
>
> Whatever you want to do, you have to do something else first.
have fun
greg
--
why do you trust your compiler?
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.linux-learn.org/faqs