Getting Data In

How to extract out a field and replace it if found in key word

rey_1993
New Member

For example my field is file_name, which contain a string " Hi Hello Hi".
My search is file_name =hello | eval keyword = if(file_name== "hello" , "hello") | table keyword

this gives me an error which don let me create a new field call keyword with hello in it.

Can anyone help me with this?

Tags (4)
0 Karma

lukejadamec
Super Champion

Your problem is that you don't have a false option in the statement. Try adding one like this:

file_name =hello | eval keyword = if(file_name== "hello" , "hello","goodbye") | table keyword

If you would rather change the value in keyword only if file_name is "hello", and other wise use the contents of file_name then use this:

file_name =hello | eval keyword = if(file_name== "hello" , file_name) | table keyword
0 Karma

lukejadamec
Super Champion

I believe you can do that with sed. With sed you can basically change the value that contains 'hello' to be just 'hello', and it works with wildcards.
Unfortunately, I don't know sed.

0 Karma

rey_1993
New Member

what are some ways i can do that?

0 Karma

lukejadamec
Super Champion

No, you can't use wildcards like that.

0 Karma

rey_1993
New Member

Hi there,
Can i do something like file_name=star"hello"star
I keep getting error on this
sorry cant display star here thats why i put star

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Observability Simplified: Combining User Experience, Application Performance & ...

Tech Talk Observability Simplified: Combining User Experience, Application Performance & Network ...

Event Series May & June: From Network Visibility to Service Intelligence

Unifying the Network: Moving from Alert Noise to Service Intelligence with Splunk ITSI In today’s hybrid ...

Global Splunk User Group Events: May + June 2026

Your Splunk Community Awaits: Discover Upcoming User Group Events Worldwide    Staying ahead in the fast-paced ...