Splunk Dev

Rex Field=All Fields mode=sed

tuanledang1120
Engager

Hi,

I'm trying to do a sed (replacing comma with _) on all fields, instead of having to specify which field I want to do the sed command on. Is that possible?

I tried to do field=*, but that did not work.

Thanks.

Tags (1)
0 Karma
1 Solution

javiergn
Super Champion

Alternatively you could use foreach:

| foreach * [eval <<FIELD>>=replace(<<FIELD>>, ",", "_" )]

View solution in original post

ddrillic
Ultra Champion

If you like, you can take it to props.conf.

We do the following to remove spaces -

# :"   kkkki    " -- remove spaces
SEDCMD-trim-ws1 = s/(:\")(\s+)?(\w+)(\s+)?(\")/\1\3\5/g

So, it's a sed command at the props.conf level.

In your case, the following should work -

SEDCMD-replace = s/,/_/g
0 Karma

javiergn
Super Champion

Alternatively you could use foreach:

| foreach * [eval <<FIELD>>=replace(<<FIELD>>, ",", "_" )]

tuanledang1120
Engager

This works! Thanks a lot!

0 Karma

sundareshr
Legend

Try field=_raw OR you don't need to specify a field. You could just do rex mode=sed "your regex"

0 Karma

tuanledang1120
Engager

I tried this but it didn't work.

0 Karma
Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...