Pi Horse
Pi Horse

Reputation: 2430

Regex - Shell scripting

I have a file which looks like this :

{
    "0" : NumberLong(654654),
    "1" : NumberLong(31321),
    "2" : NumberLong(44534564),
    "3" : NumberLong(464564645),
}

My output should be something like this :

654654
31321
44534564
464564645

I tried to do this :

grep -Po ' NumberLong\("\K[^"]*' file

But it doesn't seem to work for me.

Upvotes: 0

Views: 78

Answers (3)

signjing
signjing

Reputation: 98

Use this: grep -Po "(?<=\()[^)]+" data.txt 654654 31321 44534564 464564645

Upvotes: 0

Rakesh KR
Rakesh KR

Reputation: 6527

Try

grep -Po ' NumberLong\(\K\d+' file

Upvotes: 2

anubhava
anubhava

Reputation: 784918

Try this grep:

grep -Po ' NumberLong\(\K[^)]*' file
654654
31321
44534564
464564645

OR this grep:

grep -Po ' NumberLong\(\K\d+' file
654654
31321
44534564
464564645

Upvotes: 2

Related Questions