man tail
говорит:
-n, --lines=[+]NUM
output the last NUM lines, instead of the last 10;
or use -n +NUM to output starting with line NUM
поэтому вы можете сделать
tail -n +51 myfile >>tmp
Вместо замены всех строк в newpw.txt
,
было бы лучше чтобы создать новый файл, перебирая имена пользователей в старом, например:
cut -d: -f1 pw.txt | while read -r user; do
echo "$user:$(openssl passwd ABCXYZ)"
done > newpw.txt
mv newpw.txt pw.txt