Splunk Search

Eval command on a field with multiple words

cmak
Contributor

I want to use the eval command to create another field using an existing field. However, the existing field has multiple words. Normally, I would use quotation marks around the field, but eval treats that as a string.

|eval newfield="My Old Field"

This code would simple use the string "my Old Field" instead of values from a field called "My Old Field". How do i fix this?

Tags (3)
0 Karma
1 Solution

jonuwz
Influencer
|eval newfield=$My Old Field$

View solution in original post

gkanapathy
Splunk Employee
Splunk Employee

Another way is to use single quotes for field names with difficult characters:

eval newfield='My Old Field'

Note that this works in eval and where clauses, but quoting in search commands in general is inconsistent.

cmak
Contributor

Great, this works for advanced XML dashboards

0 Karma

jonuwz
Influencer
|eval newfield=$My Old Field$

cmak
Contributor

Great, it works 🙂

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...