How would be the correct regex to match only the first occurence of
the pattern 3.*6.
I'm trying with 3.*6 trying to match only 34rrte56, but with my current regex is matching 4rrte567890123456789123powiluur56. And if I try with ?
doesn't print anything
Thanks for your help. I want to do it in grep because I need to extract the matched strings using grep -o.
Actually, for the first example, I want to match only things that are between 3 and 6. That would be fine, not needed to match
only the first occurrence.
But for this new string, I want to match only the pattern 347 + something + 35 + 4 characters. And
After the patterns always follow 6789. But with the regex I'm trying is not printing anything.
The match strings should be those 2 in red:
Maybe could be done with grep this.
Thanks in advance.
Last edited by Ophiuchus; 08-28-2013 at 02:58 AM..
It is not directly possible with grep because it matches regular expressions line by line.
If you can break the line into multiple lines, say by inserting a newline after this pattern is found, then you can use grep to extract all the matches.
I'm trying to get some exclusions into our sendmail regular expression for the K command. The following configuration & regex works:
LOCAL_CONFIG
#
Kcheckaddress regex -a@MATCH
+<@+?\.++?\.(us|info|to|br|bid|cn|ru)
LOCAL_RULESETS
SLocal_check_mail
# check address against various regex... (0 Replies)
Hi,
I have a simple problem but i guess stupid enough to figure it out. i have thousands rows of data. and i need to find match patterns of two columns and print the number of rows. for example:
inputfile
abd abp 123
abc abc 325
ndc ndc 451
mjk lkj... (3 Replies)
Hello All,
Bash Version: 4.1.10(1)
I'm trying to "verify" some user input. The User input will contain the "Absolute Path" a "Command" and any "Options"
of that Command.
For Example, say the user's input is:
user_input="/usr//local/myExample/check_process -p 'java' -w 10 -c 20"
I... (6 Replies)
I have two files. The first containing a header and six columns of data.
Example file 1:
Number SNP ID dbSNP RS ID Chromosome Result_Call Physical Position
787066 SNP_A-8575395 RS6650104 1 NOCALL 564477
786872 SNP_A-8575125 RS10458597 1 AA ... (13 Replies)
I have a file that contains the 2 following lines (from /proc/mounts)
/dev/sdc1 /mnt/backup2 xfs rw,relatime,attr2,noquota 0 0
/dev/sdb1 /mnt/backup xfs rw,relatime,attr2,noquota 0 0
I need to match the string in the second column exactly so that only one result is returned, e.g.
> grep... (2 Replies)
Hey everyone,
Basically, all I'm looking for is a way to regex for not a certain string. The regex I'm looking to avoid matching is:
D222
i.e. an equivalent of:
awk '!/D222/'
The problem is that I use this in the following command in a Bash script:
ls ${source_directory} | awk... (1 Reply)
Hi,
I've been trying to write a regex to use in egrep (in a shell script) that'll fetch the names of all the files that match a particular pattern. I expect to match the following line in a file:
Name = "abc"
The regex I'm using to match the same is:
egrep -l '(^) *= *" ** *"$' /PATH_TO_SEARCH... (6 Replies)
Hi ,
supoose i have a file in which a word is repeated so many times.
I just want the firts occurence of that word through grep and it should not go to the next one means get the first occurence and stop there.
Suggest me some solutions.
Thanks
Namish (10 Replies)
I am using grep to pull out info from a file.
The line I am searching for begins:
START TIME - Tue Sep 11 16:40:00.
There are mutiple lines of START TIME. I need the FIRST occurence ONLY.
My grep is as follows:
start="$( grep 'START TIME' filename | cut -c15-33)"
If I echo or cat... (2 Replies)