[Top][All Lists]

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

Re: grep

From: Stepan Kasal
Subject: Re: grep
Date: Mon, 5 Jul 2004 21:45:41 +0200
User-agent: Mutt/1.4.1i

----- Forwarded message from Daniel Skinner <address@hidden> -----
Date: Fri, 2 Jul 2004 11:28:18 -0500
To: "Stepan Kasal" <address@hidden>

GNU bash, version 2.05b.0(1)-release (i486-slackware-linux-gnu)
The base system is roughly Slackware10 rc1, I'll be upgrading to the
official slack10 within the next few weeks.

What I find interesting is working within the directory ~/sandbox the
problem seemed to deteriorate so that it ALWAYS replaces the first set
of characters with the number 2, no matter what the file was called.
This was after many acts of setting and moving files etc. I created a
new directory called gnudebug and moved the file into it. The problem of
it happening EVERYTIME alleviated and it went back to happening as
normal. I don't have enough of an understanding of the workings here as
to why the above would happen. To this time if I go to that directory it
still happens.

I also looked at it from your perspective and tried to recreate the
problem as I listed it. The problem did NOT appear. I created a file and
added two lines

myphone is this 9876543211
myblue is not listed

I then did what I needed to do, so as to recreate the problem but the
problem did not present itself. Which leads me to believe that perhaps
it has to do with the formatting of the file that I'm grep'ing.

I played with the dump of the file im grep'ing and it was in fact due to
the formatting. The 'phone' and the other characters with the word was
enclosed in a brackets [phone..2] after removing the brackets the
problem did not persist. Of further interest was the number 2 that's
actually enclosed in the brackets. I decided to change that number to 1.
the name of the file was still 2 but now the problem didn't persist. I
then changed the name of the file to 1 ( the same number that's now in
the brackets of the file ) and the problem showed up again accept now it
just listed the number 1 in the grep return instead of 2

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

But if its done as you suggested it works :D

-- Daniel Skinner, Just another noob causing havoc to the ones who know
what their doing :D

So is this a feature? I was thinking of ways to use it.. hehe

-----Original Message-----
From: Stepan Kasal [mailto:address@hidden 
Sent: Thursday, July 01, 2004 10:00 AM
To: Daniel Skinner
Cc: address@hidden
Subject: Re: grep

  thank you for your bug report.

You observed an unexpected behaviour of the commands
> tmp1=`grep phone 2`
> echo $tmp1

As you stated before that the output of the grep command itself works
as expected, the problem must be caused by your shell.

Which shell do you use? Bash, tcsh, ash, or another?
Which version of the shell? Which OS do you use?

What if you try to replace the first command by

        tmp1=$(grep phone 2)

and/or the second one by

        echo "$tmp1"

What if you inspect the variable by another means by using the
command "set", for example?

        Stepan Kasal

----- End forwarded message -----

reply via email to

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