Splunk Search

How to extract filename from the path?

eduspk
Explorer

Hi All

I want to extract file name from the path

Ex:

..../../default/folder/temp.txt

output:

Filename
temp.txt

0 Karma
1 Solution

vnravikumar
Champion

Hi @eduspk

Try like and let me know

| makeresults 
| eval path="..../../default/folder/temp.txt" 
| rex field=path ".*\/(?<filename>.*)$"

View solution in original post

vnravikumar
Champion

Hi @eduspk

Try like and let me know

| makeresults 
| eval path="..../../default/folder/temp.txt" 
| rex field=path ".*\/(?<filename>.*)$"

View solution in original post

eduspk
Explorer

Thanks for quick reply.

0 Karma
Take the 2021 Splunk Career Survey

Help us learn about how Splunk has
impacted your career by taking the 2021 Splunk Career Survey.

Earn $50 in Amazon cash!