If you perform a grep command with multiple lines, and multiple words per line, the output seems to be stored in an array by word rather than by line. How can you change it so that it’s stored per line?
For example:
first_title=( $(egrep -o 'class\=\"title\" title\=\"'.\{1,80\} index.html
| egrep -o title\=\".*\"\> | sed 's/title\=\"//g' | sed 's/">//g') )
echo ${first_title[0]}
If this returned 10 lines, and the first read “This is a line”
It would only output “This”
You can use IFS to change the field separator: