Splunk Search

Is there a way to extract fields which is : separated

Hema_Nithya
Explorer

John:x:/home/John:/bin/bash 

 

is there a way to extract the field from above with colon separated.  We have many users in the above format from /etc/passwd 

John - username 

x - passwd 

/home/John - path 

Labels (3)
Tags (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| rex "(?<username>[^:]+):(?<passwd>[^:]+):(?<path>[^:]+)"

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex "(?<username>[^:]+):(?<passwd>[^:]+):(?<path>[^:]+)"
0 Karma

Hema_Nithya
Explorer

How to deal with the empty fields between . Example there is empty field between passwd and after home directory 

userid:passwd: :/home/John: : 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex "(?<username>[^:]*):(?<passwd>[^:]*):(?<path>[^:]*)"
0 Karma

Hema_Nithya
Explorer

Thank you , let me check and update you ! 

0 Karma
Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...