In a bash script, I´d like to extract a variable string from a given string. I mean, i´d like to extract the string file.txt from the string:
This is the file.txt from my folder.
I tried:
var=$(echo "This is the file.txt from my folder.")
var=echo ${var##'This'}
...
but I´d like to make it in a cleaner way, using the expr, sed or awk commands.
Thanks
Edited:
I found another way (nevertheless, the answer with the sed command is the best one for me):
var=$(echo 'This is the file.txt from my folder.')
front=$(echo 'This is the ')
back=$(echo ' from my folder.')
var=${var##$front}
var=${var%$back}
echo $var
