The linux command extracts one line every fixed line for file operations

Requirements: There is a large file that wants to extract one line every certain number of lines. It is often used to split files into training set and development set.

    awk '{if (NR%1333 == 0)  print $0; }' train.all > valid.en
    awk '{if (NR%1333 != 0)  print $0; }' train.all > train.en

Note: This is to extract a piece of data every 1333 lines as the content of the valid.en file, which can be modified as needed.

Guess you like

Origin blog.csdn.net/Answer3664/article/details/108090169