echo "import org.slf4j.LoggerFactory
class UpdateAvamDb {
private final def DEFAULT_STALE_BACKUP_HOURS = 1.0" \
| awk '/DEFAULT_STALE_BACKUP_HOUR/{print $NF}'
output
1.0
echo "import .... \ | is a quick way to perform a test with your data, rather than put it into a file. The awk code block will perform the same function if you replace the print "..." | with the input filename at the end:
awk '/..../{print $NF}' myFile
1.0
And your heading says, store value in variable, so here we go:
myVar=$(awk '/DEFAULT_STALE_BACKUP_HOUR/{print $NF}')
echo "myVar=$myVar"
1.0
AND based on your latest comment NOT to get all values. (I hope you only want the first one)
myVar=$(awk '/DEFAULT_STALE_BACKUP_HOUR/{print $NF;exit}')
echo "myVar=$myVar"
1.0
We exit file processing as soon as we match 'DEFAULT....' and print the value.
Anyway!, awk is reading its input, either from a pipe or the file, and asking "does this line have the pattern "DEFAULT_STALE_BACKUP_HOUR" anywhere inside it?" . When it finds a line with that, it will then print the last field on the line, specfied with $NF. NF is an variable that gets set for each line that is read and means 'Number of Fields'. Adding the $ to the front then "converts" the expression to another common awk idom, in this case $6, which means print the 6th field from the current line.
A good tutorial about awk is at Grymoire's awk tutorial
IHTH
P.S.
(The awk code is simple, but fragile because of your question is very specific. It is not a generalized answer. We'd need to see a better question definition to provide a solution that will work for more than just DEFAULT_.... )
grep; try searching a bit on this site. There are plenty of examples.