perl -ne'splice@l,rand$.,0,$_}{print@l' #### my @lines; splice @lines, rand $., 0, $_ while <>; print @lines;