I have couple of lines like these as a part of a file
the jdbc:mondrian:DataSource=abcd_datasource
the jdbc:mondrian:DataSource=efgh_datasource
the jdbc:mondrian:DataSource=hijk_datasource
the jdbc:mondrian:DataSource=lmno_datasource
I want to extract the strings 'abcd','efgh','hijk','lmno'
How to extract them? This is what I have tried so far:-
datasource_delimiter="_datasource"
logFileName=${1}
errorLogLines=($(grep -i "_datasource" $logFileName))
for errorLogLine in ${errorLogLines[@]}
do
if [[ "$errorLogLine"~="jdbc:mondrian:DataSource=([a-zA-Z0-9]+)_datasource" ]]
then
# what should I put here?
fi
done
Thanks
-iin the grep? Your regex requires_datasourceto be lowercase elsewhere, so making it case-insensitive in the first-pass filter doesn't buy much.expr, that's very bad form (not actually built into bash, much slower than using a builtin).