次の値を含むファイルがあります。
Server1,12.22.21.13,1234,[email protected]
Server2,12.12.12.12,1223,[email protected]
Server3,13.11.11.11,1234,[email protected]
Server4,11.11.11.11,1234,[email protected]
メールアドレスに基づいてファイルを分割したいです。電子メールを含むすべての行[Eメール保護]というファイルに表示されます。ファイル1など。
これは非常に大きなファイルなので、ケースの説明にすべての電子メールIDをハードコードすることはできません。
ベストアンサー1
(ぼんやり)
awk -F"," '{ print $0 >> $4".csv"}' filename
説明する:
-F"," -- Use "comma" field separator (FS)
$0 -- the whole line of input
$4 -- the 4-th field of line ($NF -- the last field)
>> -- redirection operator, from `info gawk':
'print ITEMS >> OUTPUT-FILE'
This redirection prints the items into the preexisting output file
named OUTPUT-FILE. The difference between this and the single-'>'
redirection is that the old contents (if any) of OUTPUT-FILE are
not erased. Instead, the 'awk' output is appended to the file. If
OUTPUT-FILE does not exist, then it is created.