[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grep

From: Chris F.A. Johnson
Subject: Re: grep
Date: Mon, 5 Jul 2004 17:03:51 -0400 (EDT)

On Mon, 5 Jul 2004, Stepan Kasal wrote:

----- Forwarded message from Daniel Skinner <address@hidden> -----
Date: Fri, 2 Jul 2004 11:28:18 -0500
To: "Stepan Kasal" <address@hidden>
So in conclusion:
If the line in a file you are grep'ing looks like this

[mysillygrep_2] This is my grep

And the name of this file is the same as the number

$ ls

And you issue the following commands

tmp=`grep silly 2`
echo $tmp

it returns the following as the line due to the brackets

2 This is my grep

Instead of the actual line which should be

[mysillygrep_2] This is my grep

    The grep command DOES return the expected value, as can be seen

$ echo "$tmp"
[mysillygrep_2] This is my grep

    If you do not quote the variable, filename expansion is done, and
    [mysillygrep_2] will match the file 2.

$ echo $tmp
2 This is my grep

    If you had a file y, that would be printed, as would any other
    files matching the pattern:

$ touch y l g
$ echo $tmp
2 g l y This is my grep

        Chris F.A. Johnson                      http://cfaj.freeshell.org
                Everything in moderation -- including moderation

reply via email to

[Prev in Thread] Current Thread [Next in Thread]