Subsrt ?

I have 7 fields, the last field is $7 and how do I write subsrt to get only
FieldActivity or FieldOrder or Case
ex: type = FieldActivity ;
it start at $7 and end at Modify ??

Thanks,

LMWC|02/28/2006 00:19:42|||||FieldActivity Modify 10071 20072 30073
CXT9|02/28/2006 02:36:31|||||FieldActivity Modify 10171 20172 30173
CXT9|02/28/2006 02:21:31|||||FieldOrder Modify 10141 20142
JAKN|02/28/2006 00:40:08|||||Case Modify 10101 20102 30103 40104

Hi, i am not sure how substr does it, i have an awk version if that will help you.

#!/bin/bash

awk -F"[ |]" '{print "Type is:" $8}' $filename  
#-F option sets <space> and <|> are separators. The 8th field is what you need.

echo 'LMWC|02/28/2006 00:19:42|||||FieldActivity Modify 10071 20072 30073' | nawk -F'|' '{print substr($NF, 1, index($NF, " "))}'
echo 'LMWC|02/28/2006 00:19:42|||||FieldActivity Modify 10071 20072 30073'  | sed 's#.*|\([^ ][^ ]*\).*#\1#'

Here is my code and it work

type = substr($7,1,index($7,"Modify")-2);

Hope that someone can learn it from this :slight_smile: and thanks for your sharing
Cheers,