С GNU grep:
s="STRINGIMLOOKINGFOR"
grep -Poz "$s"'.*(\n.*){3}' file | grep -v "$s" | tail -n 6
Text 10 Text 11 Text 12 Text 15 Text 16 Text 17
Попробуйте это,
echo "http://domain1.com/subfolder1/http://domain2.com/subfolder2" | sed 's/^http.*http:/http:/'
http://domain2.com/subfolder2
Если у вас никогда не было:в URI, вы можете сделать это только с помощью встроенных функций bash.
function last_addr(){
IFS=:
string="$1"
array=($string)
echo -n http:; echo ${array[-1]}; unset IFS
}
last_addr 'http://domain1.com/subfolder1/http://domain2.com/subfolder2'