pcregrep

pcregrep multiline SQL match

安稳与你 提交于 2021-01-28 05:57:19
问题 I'm trying to match following multiline SQL code with pcregrep: create table work.W4XLP0D as select distinct Name, ('ABCD') as xxx length = 4 from &SYSLAST where Name='Alfred' ; I wanna match distinct and ('ABCD') but it's possible that there are more than one Attributes in select statment... If tried the following: [y1e1819@sasbidientw01 ~]$ pcregrep -M '(\n).*\(\".*\"\) as' *.sas double_distinct.sas: Name, ("ABCD") as xxx length = 4 But I'm not able how to say that there can be multiple

Get a block from an XML file using data from a source file

核能气质少年 提交于 2019-12-23 02:00:06
问题 I revamped this question since I've been reading a bit on XML. I have a file source file that contains a list of AuthNumbers. 111222 111333 111444 etc. I need to search for the numbers in that list and find them in a corresponding XML file. In the xml file the line is formatted as such: <trpcAuthCode>111222</trpcAuthCode> This can be achieved quite painlessly using grep however I require the entire block containing the transaction. The block starts with: <trans type="network sale" recalled=

Get a block from an XML file using data from a source file

江枫思渺然 提交于 2019-12-08 03:45:30
I revamped this question since I've been reading a bit on XML. I have a file source file that contains a list of AuthNumbers. 111222 111333 111444 etc. I need to search for the numbers in that list and find them in a corresponding XML file. In the xml file the line is formatted as such: <trpcAuthCode>111222</trpcAuthCode> This can be achieved quite painlessly using grep however I require the entire block containing the transaction. The block starts with: <trans type="network sale" recalled="false"> or <trans type="network sale" recalled="false" rollback="true"> and/or some other variations.

How to check if one file is part of other?

房东的猫 提交于 2019-12-06 20:25:10
问题 I need to check if one file is inside another file by bash script. For a given multiline pattern and input file. Return value: I want to receive status (how in grep command) 0 if any matches were found, 1 if no matches were found. Pattern: multiline, order of lines is important (treated as a single block of lines), includes characters such as numbers, letters, ?, &, *, # etc., Explanation Only the following examples should found matches: pattern file1 file2 file3 file4 222 111 111 222 222 333

How to check if one file is part of other?

我与影子孤独终老i 提交于 2019-12-05 01:24:44
I need to check if one file is inside another file by bash script. For a given multiline pattern and input file. Return value: I want to receive status (how in grep command) 0 if any matches were found, 1 if no matches were found. Pattern: multiline, order of lines is important (treated as a single block of lines), includes characters such as numbers, letters, ?, &, *, # etc., Explanation Only the following examples should found matches: pattern file1 file2 file3 file4 222 111 111 222 222 333 222 222 333 333 333 333 444 444 the following should't: pattern file1 file2 file3 file4 file5 file6

How can I search for a multiline pattern in a file?

妖精的绣舞 提交于 2019-11-25 23:46:40
问题 I needed to find all the files that contained a specific string pattern. The first solution that comes to mind is using find piped with xargs grep : find . -iname \'*.py\' | xargs grep -e \'YOUR_PATTERN\' But if I need to find patterns that spans on more than one line, I\'m stuck because vanilla grep can\'t find multiline patterns. 回答1: So I discovered pcregrep which stands for Perl Compatible Regular Expressions GREP . For example, you need to find files where the ' _name ' variable is