How to use a string as a delimiter shell script
- by Dan
I am reading a line and am using regex to match it in my script. (/bin/bash)
echo $line | grep -E '[Ss][Uu][Bb][Jj][Ee][Cc][Tt]: [Hh][Ee][Ll][Pp]' > /dev/null 2>&1
if [[ $? = "0" && -z $subject ]]; then
subject=`echo $line | cut -d: -f2` > /dev/null
echo "Was able to grab a SUBJECT $line and the actual subject is -> $subject" >> $logfile
fi
now my problem is that i use the colon as the delimiter. but sometimes the email will have multiple colons in the subject and so I am not able to grab the whole subject because of that. I am looking for a way to grab everything after the colon following subject. even is there is a way to loop through and check for a colon or what. maybe cut allows you to cut with a string as delimiter? Not sure...any ideas?
Thanks!