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>.*)$"

eduspk
Explorer

Thanks for quick reply.

0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...