I have a file in which have values in following format-
20/01/2012 01:14:27;UP;UserID;User=bob email=abc@sample.com
I want to pick each value from this file (not labels). By saying label, i mean to say that for string email=abc@sample.com, i only want to pick abc@sample.com and for sting User=bob, i only want to pic bob. All the Space separated values are easy to pick but i am unable to pick the values separated by Semi colon. Below is the command i am using in awk–
awk '{print "1=",$1} /;/{print "2=",$2,"3=",$3}' sample_file
In $2, i am getting the complete string till bob and rest of the string is assigned to $3. Although i can work with substr provided with awk but i want to be on safe side, string length may vary.
Can somebody tell me how to design such regex to parse my file.
You can set multiple delimiters using
awk -F:Results:
EDIT:
You can remove anything before the equal signs using
sub (/[^=]*=/,"", $i). This will allow you to just print the ‘values’:Results: