I'm trying to use the output of this in a for loop:
$wc -l example.mgn | awk '{print $1}'
12
however, I get this:
for i in {1..`wc -l example.mgn | awk '{print $1}'`}; do echo $i; done
{1..12}
Brace expansion occurs before any other type of expansion, you can only include literal values in braces. For example, {1..12}
is valid, but you can't replace either 1 or 12 with a command that produces a number.
Instead, use
for ((i=1; i<= $(wc -l < example.mgn); i++)); do
echo "$i"
done