14

各要約の間に空の行がある1000個の要約を持つ大きなテキストファイルがあります。このファイルを 1000 個のテキスト ファイルに分割したいと考えています。私のファイルは次のようになります

16503654    Three-dimensional structure of neuropeptide k bound to dodecylphosphocholine micelles.      Neuropeptide K (NPK), an N-terminally extended form of neurokinin A (NKA), represents the most potent and longest lasting vasodepressor and cardiomodulatory tachykinin reported thus far.  

16504520    Computer-aided analysis of the interactions of glutamine synthetase with its inhibitors.        Mechanism of inhibition of glutamine synthetase (EC 6.3.1.2; GS) by phosphinothricin and its analogues was studied in some detail using molecular modeling methods. 
4

3 に答える 3

45

分割を使用して、「出力ファイルあたりの行数」を 2 に設定できます。各ファイルには、1 つのテキスト行と 1 つの空の行が含まれます。

split -l 2 file
于 2013-04-29T07:27:12.760 に答える
4

csplit コマンドはいつでも使用できます。これはファイル スプリッターですが、正規表現に基づいています。

次の行に沿った何か:

csplit -ks -f /tmp/files INPUTFILENAMEGOESHERE '/^$/'

これはテストされておらず、少し調整が必要な場合があります。

CSPLIT

于 2013-04-29T07:30:10.243 に答える
4

このようなもの:

awk 'NF{print > $1;close($1);}' file

これにより、ファイル名が抽象番号である 1000 個のファイルが作成されます。この awk コードは、最初のフィールド ($1) から名前が取得されたファイルにレコードを書き込みます。これは、フィールド数が 0 (NF) を超える場合にのみ行われます。

于 2013-04-29T07:16:34.650 に答える