Assuming bash is the right tool, there are a few ways:
- disable filename expansion temporarily
- use read with IFS
- use the substitution feature of bash expansion
Disabling expansion:
line="/path/IntegrationFilter.java:150: * <td>http://abcd.com/index.do</td>"
set -f
OIFS=$IFS
IFS=$'\n'
result_array=( `echo "$line"| sed 's/:/\n/1' | sed 's/:/\n/1'`)
IFS=$OIFS
set +f
echo "${result_array[0]}"
echo "${result_array[1]}"
echo "${result_array[2]}"
(note we also had to set IFS, otherwise each part of the contents ends up in result_array[2], [3], [4], etc.)
Using read:
line="/path/IntegrationFilter.java:150: * <td>http://abcd.com/index.do</td>"
echo "$line"
IFS=: read file number match <<<"$line"
echo "$file"
echo "$number"
echo "$match"
Using bash parameter expansion/substitution:
line="/path/IntegrationFilter.java:150: * <td>http://abcd.com/index.do</td>"
rest="$line"
file=${rest%%:*}
[ "$file" = "$line" ] && echo "Error"
rest=${line#$file:}
number=${rest%%:*}
[ "$number" = "$rest" ] && echo "Error"
rest=${rest#$number:}
match=$rest
echo "$file"
echo "$number"
echo "$match"