Following is a sample script that I have written
line="/path/IntegrationFilter.java:150: * <td>http://abcd.com/index.do</td>"
echo "$line" <-- "$line" prints the text correctly
result_array=( `echo "$line"| sed 's/:/\n/1' | sed 's/:/\n/1'`)
echo "${result_array[0]}"
echo "${result_array[1]}"
echo "${result_array[2]}" <-- prints the first filename in the directory due to wildcard character * .
How to get the text “* http://abcd.com/index.do ” printed instead of the filename when retrieved from an array?
Assuming bash is the right tool, there are a few ways:
Disabling expansion:
(note we also had to set IFS, otherwise each part of the contents ends up in result_array[2], [3], [4], etc.)
Using read:
Using bash parameter expansion/substitution: