4
votes
5answers
150 views

Bash script programming: how to match pattern in string?

How I can get this whole value 7I45432ZX from below lines: PW*3434*453*256*PE*UB PO*00*NE*7I4543 2ZX**20140617 PW*3434*453*256*PE*UB PO*00*NE*7I4543 2ZX**20140617 This is the code I tried: grep ...
4
votes
2answers
648 views

regex search works with `grep -E` but not with bash script?

I use the same regex with grep and it gives me a match but when doing it in a bash script, it return no match. Test String(part of the file testregex.txt): <a ...
2
votes
1answer
2k views

Using Modifiers of Perl-compatible Regex (PCRE) in grep

According to grep --help and man grep, we can use the -P option in order to interpret the pattern as a Perl regular expression (PCRE, to be precise), instead of the default POSIX basic regular ...
0
votes
1answer
207 views

how can i use grep to find IPV4 Number in a pcap file with regx syntac?

I'm new in ubuntu. I have this IP regex '\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}\b' I have a network pcap file, I want to use this regex and the grep -e to find all IP address in the ...
3
votes
1answer
95 views

Did grep change how it uses regexp?

I used to run commands like: find /dev | grep sd* to output a list of all the drives attached to my computer. It appears that I now have to add any random character before the star in order to get the ...
1
vote
1answer
498 views

Grep Regex match not returning result as expected

I have several Ubuntu servers and there is some behavior that has me curious. On any newly installed machine (Ubuntu Server 12.04.3 LTS), if I run: echo "testbla123" | grep -P -o [0-9]* This will ...
1
vote
0answers
135 views

Grep word in one file, and use that word to match in another file, adding the thing that follows the match [closed]

I want to grep several words in file1, and use each word to grep what follows after its match in file2. And then I want to add the thing that followed the match to the word I used into file03, so that ...
4
votes
1answer
129 views

Custom GREP with asterisks and anchors?

I have lots of EDI files (which is pretty much a single line of gibberish text) that are about 300mb/pcs. I'm looking to pattern matching this: `*UP*605284466346 {lots of other stuff inbetween with ...
4
votes
1answer
9k views

How to find a folder on my server with a certain name?

I have a directory somewhere on my server wth the name "exampledocs". I tried to find it's location using: ls -d */ | grep -E 'exampledocs' and find * -regextype posix-extended \-regex ...
3
votes
3answers
2k views

grep for string not preceded by another string

Is it possible, using grep, to search for instances of John Smith but exclude instances of Mr John Smith?
1
vote
1answer
2k views

How to make grep display only the matching regexp?

I am trying to find data from files using grep, but grep usually prints out the filename as well as the line where the term is found. In this case, I am looking for a special regexp and I want grep ...