歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux文件分割與合並:split&cat(一)

Linux文件分割與合並:split&cat(一)

日期:2017/2/25 10:37:56   编辑:Linux教程

  Linux下文件分割可以通過split命令來實現,可以指定按行數分割和安大小分割兩種模式。Linux下文件合並可以通過cat命令來實現,非常簡單。

  在Linux下用split進行文件分割:

  模式一:指定分割後文件行數

  對與txt文本文件,可以通過指定分割後文件的行數來進行文件分割。

  命令:split -l 300 large_file.txt new_file_prefix

  模式二:指定分割後文件大小

  對於可執行文件等二進制文件,則不能通過文件行數來進行文件分割,此時我們可以指定分割大小來分隔文件。

  命令:split -b 10m large_file.bin new_file_prefix

  對二進制文件我們同樣也可以按文件大小來分隔。

  在Linux下用cat進行文件合並:

  命令:cat small_files* > large_file

  Linx文件分割命令split manpage:

  NAME

  split - split a file into pieces

  SYNOPSIS

  split [OPTION] [INPUT [PREFIX]]

  DESCRIPTION

  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

Copyright © Linux教程網 All Rights Reserved