Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Search a string inside a pattern matched block of a file Post 302996207 by Corona688 on Friday 21st of April 2017 12:01:27 PM
Old 04-21-2017
Code:
awk '/STARTREGEX/ { P=1 } ; /ENDREGEX/ { P=0 } ; P && /LINEREGEX/' datafile

If that doesn't work we will need a LOT more details.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to search a pattern inside a zipped file ie (.gz file) with out unzipping it

How to search a pattern inside a zipped file ie (.gz file) with out unzipping it? using grep command.. Bit urgent.. pls..help me (2 Replies)
Discussion started by: senraj01
2 Replies

2. UNIX for Dummies Questions & Answers

Search and Parse string from inside a File

Hello, I barely know the basics, but I am very determined to learn. I want to parse a few characters from each row, use that string to search another file and display the line number where I found the value in the file. I don't know if this can all be done on the command line, so I am creating a... (2 Replies)
Discussion started by: SSims
2 Replies

3. Shell Programming and Scripting

Search Mulitiple String pattern in a file

Hi, I need to search for a multiple string pattern(5 key words) in a file(similar to a flat file) ,and i need to store the output in a another file . In that file we may have mutiple occurrences of the key words.and i need only the unique. kindly help out. Thanks, Mohana Krishnan (2 Replies)
Discussion started by: krishnan_6015@y
2 Replies

4. Shell Programming and Scripting

search for the matched pattern by tracing back from the line

Hi, I want to grep the line which has 'data11'.then from that line, i need to trace back and find out the immediate line which has the same timestamp of that grepped line. for eg: log file: ----------- Process - data Process - datavalue - 2345 Process - data Process - data Process... (9 Replies)
Discussion started by: Sharmila_P
9 Replies

5. Shell Programming and Scripting

Awk search for string pattern in delimited file

I've got a semicolon delimited file. I would like to search for fields that match a pattern, and not hardcoded eg "mth". *th=something If the delimited field fulfills this condition, eg. mth=value I would like to print out both key and value for some number comparison. eg. if value > "12"... (5 Replies)
Discussion started by: alienated
5 Replies

6. Shell Programming and Scripting

Search for a pattern in a String file and count the occurance of each pattern

I am trying to search a file for a patterns ERR- in a file and return a count for each of the error reported Input file is a free flowing file without any format example of output ERR-00001=5 .... ERR-01010=10 ..... ERR-99999=10 (4 Replies)
Discussion started by: swayam123
4 Replies

7. Shell Programming and Scripting

Perl - use search keywords from array and search a file and print 3rd field when matched

Hi , I have been trying to write a perl script to do this job. But i am not able to achieve the desired result. Below is my code. my $current_value=12345; my @users=("bob","ben","tom","harry"); open DBLIST,"<","/var/tmp/DBinfo"; my @input = <DBLIST>; foreach (@users) { my... (11 Replies)
Discussion started by: chidori
11 Replies

8. Shell Programming and Scripting

How to use sed to search a particular pattern in a file backward after a pattern is matched.?

Hi, I have two files file1.txt and file2.txt. Please see the attachments. In file2.txt (which actually is a diff output between two versions of file1.txt.), I extract the pattern corresponding to 1172c1172. Now ,In file1.txt I have to search for this pattern 1172c1172 and if found, I have to... (9 Replies)
Discussion started by: saurabh kumar
9 Replies

9. Shell Programming and Scripting

Search for Pattern as output between the matched String

Hello, I have a file which has the below contents : VG_name LV_name LV_size in MB LV_option LV_mountpoint owner group y testdg rahul2lv 10 "-A y -L" /home/abc2 ... (6 Replies)
Discussion started by: rahul2662
6 Replies

10. Shell Programming and Scripting

How can I use find command to search string/pattern in a file recursively?

Hi, How can I use find command to search string/pattern in a file recursively? What I tried: find . -type f -exec cat {} | grep "make" \; Output: grep: find: ;: No such file or directory missing argument to `-exec' And this: find . -type f -exec cat {} \; -exec grep "make" {} \;... (12 Replies)
Discussion started by: cola
12 Replies
fnmatch(3C)															       fnmatch(3C)

NAME
fnmatch() - match filename patterns SYNOPSIS
DESCRIPTION
performs pattern matching as described in regexp(5) under By default, the rule qualifications for filename expansion do not apply; i.e., periods (dots) and slashes are matched as ordinary characters. This default behavior can be modified by using the flags described below. The flag argument modifies the interpretation of pattern and string. If which is defined in is set in flag, a slash character in string must be explicitly matched by a slash in pattern; it cannot be matched by either the asterisk or question mark special characters or by a bracket expression. If is set in flag, a leading period must be explicitly matched. It will not be matched by a bracket expression, question mark or asterisk. By default, a period is leading if it is the first character in string. If is set in flag, a period is leading if it is the first charac- ter in string or immediately follows a slash. If is not set in flag, a backslash character in pattern followed by any other character matches that second character in string. In par- ticular, matches a backslash in string. If is set, a backslash character is treated as an ordinary character. If flag is zero, the slash character and the period are treated as regular characters. If flag has any other value, the result is unde- fined. RETURN VALUE
If string matches the pattern specified by pattern, returns zero. Otherwise, returns non-zero. EXAMPLE
The following excerpt uses to check each file in a directory against the pattern pattern = "*.c"; while(dp = readdir(dirp)){ if((fnmatch(pattern, dp->d_name,0)) == 0){ /* do processing for match */ ... } } AUTHOR
was developed by OSF and HP. SEE ALSO
sh(1), glob(3C), thread_safety(5). STANDARDS CONFORMANCE
fnmatch(3C)
All times are GMT -4. The time now is 01:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy