I'm trying to get a portion of a line in a text files in bash but instead of the text 'field1' I wanted to use a variable. But it is not working. Suggestions
WORKS:
NomeVar=$(cut -d ":" -f 1 <<< "$(awk /campo1/ { print substr($0,48,10) } /home/ficheiro.txt)")
IT DOES NOT WORK:
fld1=campo1
NomeVar=$(cut -d ":" -f 1 <<< "$(awk /$fld1/ { print substr($0,48,10) } /home/ficheiro.txt)")