Reputation: 133
so i am trying to write a grep which finds the .epl file names or file paths in a given file.
I have tried the follwoing regexs
Part 1 : REGEX Used grep -rEco "\/(.+)\.epl|(.+)\.epl" ./index.epl
Result obtained
url => 'xyz.epl
url => 'xyz.epl
url => 'xyz.epl
url => "packet/xyz.epl
url => "/web/abc/xyz.epl
url => qq{/web/abc/xyz.epl
url => '/web/abc/def/xyz.epl
url => '/web/abc/def/xyz.epl
url => 'xyz.epl
url => 'xyz.epl
$url = "/web/abc/def/xyz.epl
var requestURL = "xyz.epl
var requestURL = "xyz.epl
<a style="float:left;" href="xyz.epl
[- Execute('components/xyz.epl
Welcome, <a href="xyz.epl
[- Execute('components/xyz.epl
<a href="xyz.epl
[- Execute(`'components/xyz.epl`
However I want it to match only the following(with or without the preceding quotes)
'xyz.epl(OR xyz.epl)
'xyz.epl
'xyz.epl
"packet/xyz.epl(OR packet/xyz.epl)
"/web/abc/xyz.epl(OR "/web/abc/xyz.epl)
/web/abc/xyz.epl
'/web/abc/def/xyz.epl
'/web/abc/def/xyz.epl
'xyz.epl
'xyz.epl
"/web/abc/def/xyz.epl
"xyz.epl
"xyz.epl
"xyz.epl
'components/xyz.epl
"xyz.epl
'components/xyz.epl
"xyz.epl
'components/xyz.epl
To obtain the desired out i tried grep -rEoc '\/(.+)\.epl|[\"\'](.+)\.epl'
However it gives me an unmatched '.
error
I removed the quotes surrounding the regex and I got
Badly placed ()'s.
please help me in achieving the correct desired output.
Upvotes: 1
Views: 615
Reputation: 133
I found the answer to my question trhough two separate sources. One is explained here . The other one was
set quote='"'; grep -E "\/(.+)\.epl|['${quote}](.+)\.epl" /index.epl
The set quote did the trick
Upvotes: 1
Reputation: 20002
How about telling what characters are accepted as part of the filenames:
grep -Eo "[0-9a-zA-Z/]*.epl" ./index.epl
Upvotes: 0