bash - How to pass filename through variable to be read it by awk -
good day,
i wondering how pass filename awk variable, in order awk read it.
so far have done:
echo file1 > aenumerar echo file2 >> aenumerar echo file3 >> aenumerar ae=`grep -c '' aenumerar` r=1 while [ $r -le $ae ]; lista=`awk "nr==$r {print $0}" aenumerar` aelist=`grep -c '' $lista` s=1 while [ $s -le $aelist ]; word=`awk -v var=$s 'nr==var {print $1}' $lista` echo $word let "s = s + 1" done let "r = r + 1" done
thanks in advance clue or other simple way bash command line
instead of:
awk "nr==$r {print $0}" aenumerar
you need use:
awk -v r="$r" 'nr==r' aenumerar
Comments
Post a Comment