把文件按关键字拆分成多个文件

By admin, 29 七月, 2018

有时候,我们需要把一个很长的文本拆分成多个文件。例如把一本书拆分成若干章节。下面命令可以做到,其中66表示重复执行66次(文本有66章)

csplit full.html '/正文/' '{66}'

如果重复次数超过100,csplit需要增加-n 4参数来用4位数命名文件名。

拆分后,文件会以xx开头,下面命令可以统一改后缀名:

find xx*|xargs -I {} mv {} {}.html

评论

Restricted HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <img src>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。
验证码
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
请输入"Drupal10"