bug-bash
[Top][All Lists]
Advanced

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

Re: Uniq pattern


From: John McKown
Subject: Re: Uniq pattern
Date: Thu, 31 Dec 2015 18:44:07 -0600

On Thu, Dec 31, 2015 at 6:15 PM, Val Krem <valkrem@yahoo.com> wrote:
>
>
>
> Hi all
> I wanted to search a line  that contains  "1235"  using
> grep   -R "1235".
> I am getting  unwanted results such as
>  01235 or 12356 and so on.
>
> How could I avoid these and get only '1235"?
>
> Val

I don't know what you mean by "only 1235". Do you mean with no leading or trailing digits? I.e. A1235B is a match, but 01235 is not. Or do you mean "a line which contains _only_ 1235 and no other characters?

For the first, this should work: egrep '(^|[^[:digit:]])1235($|[^[:digit:]])'
 
({^|[^[:digit:])) matches the beginning of the ​string (^) or a non-digit [^[:digit:]]
then the digits "1235
($|[^[:digit:]]) then matches the end of the string ($) or a non-digit.

Oh, what does this have to do with BASH????? And how is it a bug? IOW, this looks like the wrong forum. This is not a general UNIX (or Linux) question and answer forum. You might want to get an account on StackExchange 




--
Computer Science is the only discipline in which we view adding a new wing to a building as being maintenance -- Jim Horning

Schrodinger's backup: The condition of any backup is unknown until a restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

reply via email to

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