SORU
6 Ocak 2010, ÇARŞAMBA


Büyük bir Metin Dosyası Bölmek için kolay bir Yolu?

Ayrıca satır sayısı ile daha küçük dosyalara bölmek istiyorum (satır sayısı) büyük bir düz metin dosyası var. Eğer öyleyse benim dosya var etrafında 2M hatları isterim bölme içine 10 içeren dosyalar 200 k çizgiler veya 100 içeren dosyalar 20k hatları (artı bir dosya ile kalanı; olmak bölünebilen eşit önemi yok).

Ben bunu oldukça kolay Python ama merak ediyorum eğer orada herhangi bir ninja yolu bunu yapmak için kullanan bash, unix araçlarının (karşıt olarak el ile döngü ve sayma / bölümleme satır).

CEVAP
6 Ocak 2010, ÇARŞAMBA


Baktı split komutu var mı?

$ split --help
Usage: split [OPTION] [INPUT [PREFIX]]
Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...; default
size is 1000 lines, and default PREFIX is `x'.  With no INPUT, or when INPUT
is -, read standard input.

Mandatory arguments to long options are mandatory for short options too.
  -a, --suffix-length=N   use suffixes of length N (default 2)
  -b, --bytes=SIZE        put SIZE bytes per output file
  -C, --line-bytes=SIZE   put at most SIZE bytes of lines per output file
  -d, --numeric-suffixes  use numeric suffixes instead of alphabetic
  -l, --lines=NUMBER      put NUMBER lines per output file
      --verbose           print a diagnostic to standard error just
                            before each output file is opened
      --help     display this help and exit
      --version  output version information and exit

Gibi bir şey yapabilirsin:

split -l 200000 filename

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Amena

    Amena

    15 Kasım 2006
  • iZAPPA

    iZAPPA

    16 Temmuz 2010
  • talkandroid

    talkandroid

    27 Mayıs 2010