vendredi 11 août 2017

How to randomly sample lines, output them in a new file, and delete them from the original file?

I would like to select at random N lines from a big file called input_file (6250000 lines,N=1250000), output the N lines in a new file called output_file, and delete the N lines from the original file input_file.

According to this post, the first two tasks can be achieved with :

sort -R input_file | head -n $N > output_file

How to delete the selected N lines from input_file ?




Aucun commentaire:

Enregistrer un commentaire