2
I am trying to get a part of a line in bash text files 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)")
DOESN’T WORK:
fld1=campo1
NomeVar=$(cut -d ":" -f 1 <<< "$(awk /$fld1/ { print substr($0,48,10) } /home/ficheiro.txt)")
It works, thank you
– Pedro Caldeira