split分割檔案

2021-05-27 09:24:13 字數 1123 閱讀 2474

在linux下,使用split命令可以實現檔案的分割,使用 cat 命令來完成分割檔案的合併

譬如,在下面 split 命令列中的 「12m」 表示分割後的每個檔案為 12mb,「filename」 為待分割檔案,分割後的檔案自動命名為 xaa,xab,…

split:按指定的行數截斷檔案

格式: split [-n] file

[name]

引數說明:

-n: 指定截斷的每一檔案的長度,不指定預設為1000行

file: 要截斷的檔案

name: 截斷後產生的檔案的檔名的開頭字母,不指定,預設為x,即截斷後產生的檔案的檔名為xaa,xab....直到xzz

例一:

split -55 myfile ff

將檔案myfile依次截斷到名為ffaa,ffab,ffac.....的檔案中,每一檔案的長度為55行

例二:

postgressql 大型資料庫備份與回存:

因 postgres 允許**大過你系統檔案的最大容量,所以要將**

dump 到單一的檔案可能會有問題,使用 split 來進行檔案分割。

% pg_dump dbname | split -b 1m - filename.dump.

下面將檔案testfile分割成大小為98k的檔案

[root@mx1 /home/sysadmin/zhaoyj]# ls -l testfile.txt

-rw-r--r--  1 root  wheel  900410 aug 11 15:38 testfile.txt

[root@mx1 /home/sysadmin/zhaoyj]# split -b 100000  testfile.txt

[root@mx1 /home/sysadmin/zhaoyj]# ls |grep '^xa'|xargs du -sh

98k    xaa

98k    xab

98k    xac

98k    xad

98k    xae

98k    xaf

98k    xag

98k    xah

98k    xai

2.0k    xaj

split分割檔案命令

有時候乙個檔案太大要分割可以使用split命令。比如 要將 etc passwd 檔案按行分割,每10行分割為乙個新檔案,記為passwordaa,passwordbb,放在 root 下 split l 10 etc passwd root password l選項就是指定分割的行數還有乙個常用的...

linux 大檔案分割 split

1,split b 100m d a 3 test.log small test log 結果 small test log 001 small test log 002 small test log 003 每個檔案的大小為100mb 2,split b 100m test.log small t...

Linux 檔案的分割 split

檔案切割模式分為兩種 文字檔案和二進位制模式。1 文字模式 文字模式只適用於文字檔案,用這種模式切割後的每個檔案都是可讀的。文字模式又分為兩種 按最大檔案大小切割和按文字行數切割。1 按檔案大小切割 split c 50k log.log splog 將文字檔案log.log按每塊最大50k的大小進...