perl -nle"next if $.==1; $n[$_]=$_ }{ defined and print for @n" nums >nums2