如何分割个TXT文件。。。

Jason

来自: Jason(满状态长5.4CM) 2012-07-30 04:05:05

  • 徐栖

    徐栖 (But then again, I don't know) 2012-07-30 09:51:40

    SPLIT(1) BSD General Commands Manual SPLIT(1)

    NAME
    split -- split a file into pieces

    SYNOPSIS
    split [-a suffix_length] [-b byte_count[k|m]] [-l line_count]
    [-p pattern] [file [name]]

    DESCRIPTION
    The split utility reads the given file and breaks it up into files of
    1000 lines each. If file is a single dash (`-') or absent, split reads
    from the standard input.

    The options are as follows:

    -a suffix_length
    Use suffix_length letters to form the suffix of the file name.

    -b byte_count[k|m]
    Create smaller files byte_count bytes in length. If ``k'' is
    appended to the number, the file is split into byte_count kilo-
    byte pieces. If ``m'' is appended to the number, the file is
    split into byte_count megabyte pieces.

    -l line_count
    Create smaller files n lines in length.

    Mac 和 BSD 上的,不记得 Linux 和 cygwin 下有没有这个工具了。

  • Jason

    Jason (满状态长5.4CM) 2012-07-30 14:40:40

    SPLIT(1) BSD General Commands Manual SPLIT(1) NAME SPLIT(1) BSD General Commands Manual SPLIT(1) NAME split -- split a file into pieces SYNOPSIS split [-a suffix_length] [-b byte_count[k|m]] [-l line_count] [-p pattern] [file [name]] DESCRIPTION The split utility reads the given file and breaks it up into files of 1000 lines each. If file is a single dash (`-') or absent, split reads from the standard input. The options are as follows: -a suffix_length Use suffix_length letters to form the suffix of the file name. -b byte_count[k|m] Create smaller files byte_count bytes in length. If ``k'' is appended to the number, the file is split into byte_count kilo- byte pieces. If ``m'' is appended to the number, the file is split into byte_count megabyte pieces. -l line_count Create smaller files n lines in length. Mac 和 BSD 上的,不记得 Linux 和 cygwin 下有没有这个工具了。 ... 徐栖

    这不是EMACS插件?

    我想用EMACS解决,VIM可以相对轻松地搞定这个问题。

  • ilisp

    ilisp 2012-07-30 15:28:10

    这不是EMACS插件? 我想用EMACS解决,VIM可以相对轻松地搞定这个问题。 这不是EMACS插件? 我想用EMACS解决,VIM可以相对轻松地搞定这个问题。 Jason

    vim如何搞定呢?

  • Jason

    Jason (满状态长5.4CM) 2012-07-30 16:38:09

    vim如何搞定呢? vim如何搞定呢? ilisp

    搜下就有,国内网站有关VIM的文章比EMACS多得太多了。。。

  • Nobody

    Nobody 2012-07-30 17:24:18

    哪个方便就用哪个咯,我都不区分vim和emacs的,捡起哪个就用哪个

  • ilisp

    ilisp 2012-07-30 22:14:14

    (defun split-per-3-lines (directory prefix suffix)
    (interactive
    (let (d p s)
    (setq d (read-directory-name "Directory : "))
    (setq p (read-string "prefix : "))
    (setq s (read-string "suffix : "))
    (list d p s)))
    (save-excursion
    (goto-char (point-min))
    (let ((triplets
    (loop
    with pre = 1
    for i from 0
    do (forward-line 3)
    collect (list pre (point) i)
    do (forward-line)
    do (setq pre (point))
    until (= (point) (point-max)))))
    (dolist (triplet triplets)
    (let ((s (car triplet))
    (e (cadr triplet))
    (i (caddr triplet)))
    (write-region s e (format "%s/%s%06d%s.txt" directory prefix i suffix)))))))

  • ilisp
  • Jason

    Jason (满状态长5.4CM) 2012-07-30 23:17:06

    (defun split-per-3-lines (directory prefix suffix) (interactive (let (d p s) (defun split-per-3-lines (directory prefix suffix) (interactive (let (d p s) (setq d (read-directory-name "Directory : ")) (setq p (read-string "prefix : ")) (setq s (read-string "suffix : ")) (list d p s))) (save-excursion (goto-char (point-min)) (let ((triplets (loop with pre = 1 for i from 0 do (forward-line 3) collect (list pre (point) i) do (forward-line) do (setq pre (point)) until (= (point) (point-max))))) (dolist (triplet triplets) (let ((s (car triplet)) (e (cadr triplet)) (i (caddr triplet))) (write-region s e (format "%s/%s%06d%s.txt" directory prefix i suffix))))))) ... ilisp

    这。。。要用好EMACS,果然要学ELISP吗!?

  • ilisp

    ilisp 2012-07-31 07:41:41

    可以用键盘宏处理,可是,文件名怎么办呢?

你的回应

回应请先 , 或 注册

5051 人聚集在这个小组
↑回顶部