I am trying to store the result of a bash command within a for loop for use in a command. This is what I currently have:
for filename in /home/WIN/USER/files/*
var=$(basename ${filename%.*}) | awk -F'[_.]' '{print $1}'
do echo var
done
However, I am getting these errors:
./script.sh: line 2: syntax error near unexpected token `var=$(basename ${filename%.*})'
./script.sh: line 2: `var=$(basename ${filename%.*}) | awk -F'[_.]' '{print $1}''
Does anyone know how to fix this or how to do what I am trying to do?
Thanks.