Hi,
i like extract a single word from a file by using awk.
I have a file dateien.txt. That contains:

fuchs
du
hast
die
Gans
gestohlen
gib
sie
wieder
her

less $sysdatsi’'dateien.txt| awk ‘NR == 1’ → works fine
unfortunatly this loop not ( i dont get the individual words displayed)

counter=1
while [ $counter -lt $Anzahl ]
do
echo $counter
temp=$(less $sysdatsi’'dateien.txt| awk ‘NR == $counter’)
echo $temp
let counter=counter+1

done

Has anybody a idea?
Thanks

1 Spice up

The issue might be due to the incorrect use of single quotes in your awk command and the variable $sysdatsi

Use double-quotes instead.

counter=1
Anzahl=$(wc -l < dateien.txt) 
while [ $counter -le $Anzahl ]
do
  echo $counter
  temp=$(awk -v var="$counter" 'NR == var' dateien.txt)
  echo $temp
  let counter=counter+1
done

2 Spice ups