0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

Linux系統(tǒng)下傳輸大文件的切割與合并實例分析

馬哥Linux運維 ? 來源:馬哥Linux運維 ? 作者:Escape ? 2021-07-02 11:47 ? 次閱讀

往往是因為網(wǎng)絡(luò)傳輸?shù)南拗?,?dǎo)致很多時候,我們需要在 Linux 系統(tǒng)下進(jìn)行大文件的切割。這樣將一個大文件切割成為多個小文件,進(jìn)行傳輸,傳輸完畢之后進(jìn)行合并即可。

文件切割 - split

在 Linux 系統(tǒng)下使用 split 命令進(jìn)行大文件切割很方便

命令語法

使用實例

# 行切割文件

$ split -l 300000 users.sql /data/users_

# 使用數(shù)字后綴

$ split -d -l 300000 users.sql /data/users_

# 按字節(jié)大小分割

$ split -d -b 100m users.sql /data/users_

```bash

**幫助信息**

```bash

# 幫助信息

$ split --help

Usage: split [OPTION]。。. [FILE [PREFIX]]

Output pieces of FILE to PREFIXaa, PREFIXab, 。。.;

default size is 1000 lines, and default PREFIX is ‘x’。

With no FILE, or when FILE is -, read standard input.

Mandatory arguments to long options are mandatory for short options too.

-a, --suffix-length=N generate suffixes of length N (default 2) 后綴名稱的長度(默認(rèn)為2)

--additional-suffix=SUFFIX append an additional SUFFIX to file names

-b, --bytes=SIZE put SIZE bytes per output file 每個輸出文件的字節(jié)大小

-C, --line-bytes=SIZE put at most SIZE bytes of records per output file 每個輸出文件的最大字節(jié)大小

-d use numeric suffixes starting at 0, not alphabetic 使用數(shù)字后綴代替字母后綴

--numeric-suffixes[=FROM] same as -d, but allow setting the start value

-e, --elide-empty-files do not generate empty output files with ‘-n’ 不產(chǎn)生空的輸出文件

--filter=COMMAND write to shell COMMAND; file name is $FILE 寫入到shell命令行

-l, --lines=NUMBER put NUMBER lines/records per output file 設(shè)定每個輸出文件的行數(shù)

-n, --number=CHUNKS generate CHUNKS output files; see explanation below 產(chǎn)生chunks文件

-t, --separator=SEP use SEP instead of newline as the record separator; 使用新字符分割

‘’ (zero) specifies the NUL character

-u, --unbuffered immediately copy input to output with ‘-n r/。。.’ 無需緩存

--verbose print a diagnostic just before each 顯示分割進(jìn)度

output file is opened

--help display this help and exit 顯示幫助信息

--version output version information and exit 顯示版本信息

The SIZE argument is an integer and optional unit (example: 10K is 10*1024)。

Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,。。. (powers of 1000)。

CHUNKS may be:

N split into N files based on size of input

K/N output Kth of N to stdout

l/N split into N files without splitting lines/records

l/K/N output Kth of N to stdout without splitting lines/records

r/N like ‘l’ but use round robin distribution

r/K/N likewise but only output Kth of N to stdout

GNU coreutils online help: 《http://www.gnu.org/software/coreutils/》

Full documentation at: 《http://www.gnu.org/software/coreutils/split》

or available locally via: info ‘(coreutils) split invocation’

文件合并 - cat

在 Linux 系統(tǒng)下使用 cat 命令進(jìn)行多個小文件的合并也很方便

命令語法

-n: #顯示行號

-e: #以$字符作為每行的結(jié)尾

-t: #顯示TAB字符(^I)

cat [-n] [-e] [-t] [輸出文件名]

使用實例

# 合并文件

$ cat /data/users_* 》 users.sql

幫助信息

# 幫助信息

$ cat --h

Usage: cat [OPTION]。。. [FILE]。。.

Concatenate FILE(s) to standard output.

With no FILE, or when FILE is -, read standard input.

-A, --show-all equivalent to -vET

-b, --number-nonblank number nonempty output lines, overrides -n

-e equivalent to -vE

-E, --show-ends display $ at end of each line

-n, --number number all output lines

-s, --squeeze-blank suppress repeated empty output lines

-t equivalent to -vT

-T, --show-tabs display TAB characters as ^I

-u (ignored)

-v, --show-nonprinting use ^ and M- notation, except for LFD and TAB

--help display this help and exit

--version output version information and exit

Examples:

cat f - g Output f‘s contents, then standard input, then g’s contents.

cat Copy standard input to standard output.

GNU coreutils online help: 《http://www.gnu.org/software/coreutils/》

Full documentation at: 《http://www.gnu.org/software/coreutils/cat》

or available locally via: info ‘(coreutils) cat invocation’

作者: Escape

文章出處:【微信公眾號:馬哥Linux運維】

責(zé)任編輯:gt

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • Linux
    +關(guān)注

    關(guān)注

    87

    文章

    11171

    瀏覽量

    208479

原文標(biāo)題:Linux 下大文件切割與合并

文章出處:【微信號:magedu-Linux,微信公眾號:馬哥Linux運維】歡迎添加關(guān)注!文章轉(zhuǎn)載請注明出處。

收藏 人收藏

    評論

    相關(guān)推薦

    Linux文件系統(tǒng)的掛載過程

    Linux文件系統(tǒng)(rootfs)是Linux系統(tǒng)中所有其他文件系統(tǒng)和目錄的起點,它是內(nèi)核啟動時掛載的第一個
    的頭像 發(fā)表于 10-05 16:50 ?151次閱讀

    如何構(gòu)建Linux文件系統(tǒng)

    構(gòu)建Linux文件系統(tǒng)是一個涉及多個步驟和概念的過程,它對于Linux系統(tǒng)的啟動和運行至關(guān)重要。
    的頭像 發(fā)表于 10-05 16:47 ?150次閱讀

    如何更改Linux文件系統(tǒng)終端顯示顏色

    自己制作的簡單 Linux 文件系統(tǒng),你會發(fā)現(xiàn)終端顯示為黑白色,很不好看
    的頭像 發(fā)表于 08-12 17:29 ?295次閱讀
    如何更改<b class='flag-5'>Linux</b><b class='flag-5'>文件系統(tǒng)</b>終端顯示顏色

    如何修改buildroot和debian文件系統(tǒng)

    本文檔主要介紹在沒有編譯環(huán)境的情況下,如何修改buildroot和debian文件系統(tǒng)方法,如在buildroot文件系統(tǒng)中添加文件、修改目錄等文件操作,在debian
    的頭像 發(fā)表于 07-22 17:46 ?356次閱讀
    如何修改buildroot和debian<b class='flag-5'>文件系統(tǒng)</b>

    linux--sysfs文件系統(tǒng)

    sysfs文件系統(tǒng) sysfs,全稱為System Filesystem,是一個由Linux內(nèi)核實現(xiàn)的虛擬文件系統(tǒng)。它扮演著一個橋梁的角色,將內(nèi)核中的設(shè)備和驅(qū)動程序信息以文件的形式呈現(xiàn)
    的頭像 發(fā)表于 07-08 11:37 ?591次閱讀
    <b class='flag-5'>linux</b>--sysfs<b class='flag-5'>文件系統(tǒng)</b>

    如何使用squashfs只讀文件系統(tǒng)制作Linux系統(tǒng)文件

    在 Colibri iMX6 的 eMMC 上我們將使用以下分區(qū)規(guī)劃。BootFS 為 FAT32 格式,該分區(qū)上包含 Linux 內(nèi)核文件,device tree 等啟動文件,如果是 iMX8,則還包含一些其他固件
    發(fā)表于 01-09 11:43 ?1577次閱讀
    如何使用squashfs只讀<b class='flag-5'>文件系統(tǒng)</b>制作<b class='flag-5'>Linux</b><b class='flag-5'>系統(tǒng)</b><b class='flag-5'>文件</b>

    Linux系統(tǒng)文件比較工具集合

    Linux系統(tǒng)中,文件比較是一種常見的任務(wù),用于比較兩個文件之間的差異。文件比較可以幫助我們找出兩個
    的頭像 發(fā)表于 01-02 13:53 ?615次閱讀

    linux文件訪問權(quán)限怎么設(shè)置

    Linux 文件訪問權(quán)限是操作系統(tǒng)中一個非常重要的概念。正確地設(shè)置文件訪問權(quán)限可以保護(hù)系統(tǒng)的安全性,防止未經(jīng)授權(quán)的人員對
    的頭像 發(fā)表于 11-23 10:20 ?1364次閱讀

    linux恢復(fù)遠(yuǎn)端備份文件

    Linux系統(tǒng)中,恢復(fù)遠(yuǎn)端備份文件是一項非常重要的工作。當(dāng)我們的數(shù)據(jù)丟失或損壞時,從備份文件中恢復(fù)數(shù)據(jù)可以幫助我們恢復(fù)到之前的狀態(tài)。在本文中,我將詳細(xì)介紹如何在
    的頭像 發(fā)表于 11-23 10:08 ?444次閱讀

    linux系統(tǒng)備份與還原工具

    Linux系統(tǒng)備份與還原工具是用于備份和恢復(fù)Linux操作系統(tǒng)的工具。在日常使用中,備份和還原是非常重要的操作,可以幫助我們保護(hù)數(shù)據(jù)并快速恢復(fù)系統(tǒng)
    的頭像 發(fā)表于 11-23 10:04 ?2426次閱讀

    linux修改網(wǎng)卡ip配置文件

    Linux是一種開源的操作系統(tǒng),因此,它給用戶提供了很高的自由度,可以根據(jù)個人需要進(jìn)行各種定制和配置。其中,修改網(wǎng)絡(luò)接口配置文件是常見的操作,可以通過修改網(wǎng)卡ip配置文件來設(shè)置網(wǎng)絡(luò)接口
    的頭像 發(fā)表于 11-17 10:51 ?1997次閱讀

    Linux文件系統(tǒng)層的主要結(jié)構(gòu)

    Linux 文件系統(tǒng)體系結(jié)構(gòu)是一個對復(fù)雜系統(tǒng)進(jìn)行抽象化的有趣例子。通過使用一組通用的 API 函數(shù),Linux 可以在許多種存儲設(shè)備上支持許多種文件
    的頭像 發(fā)表于 11-10 10:37 ?508次閱讀
    <b class='flag-5'>Linux</b><b class='flag-5'>文件系統(tǒng)</b>層的主要結(jié)構(gòu)

    Linux文件系統(tǒng)特點

    Linux文件系統(tǒng)特點 文件系統(tǒng)要有嚴(yán)格的組織形式,使得文件能夠以塊為單位進(jìn)行存儲。 文件系統(tǒng)中也要有索引區(qū),用來方便查找一個
    的頭像 發(fā)表于 11-09 14:48 ?1043次閱讀
    <b class='flag-5'>Linux</b>的<b class='flag-5'>文件系統(tǒng)</b>特點

    Linux系統(tǒng)文件讀寫流程

    本文用一個最簡單的read(fd, buf, 4096)的代碼,分析它從開始讀到讀結(jié)束,在整個Linux系統(tǒng)里面波瀾壯闊的一生。本文涉及到的代碼如下。
    的頭像 發(fā)表于 11-05 09:29 ?634次閱讀
    <b class='flag-5'>Linux</b><b class='flag-5'>系統(tǒng)</b><b class='flag-5'>文件</b>讀寫流程

    基于嵌入式Linux的無線多媒體傳輸系統(tǒng)設(shè)計與實現(xiàn)

    電子發(fā)燒友網(wǎng)站提供《基于嵌入式Linux的無線多媒體傳輸系統(tǒng)設(shè)計與實現(xiàn).pdf》資料免費下載
    發(fā)表于 10-26 14:37 ?0次下載
    基于嵌入式<b class='flag-5'>Linux</b>的無線多媒體<b class='flag-5'>傳輸</b><b class='flag-5'>系統(tǒng)</b>設(shè)計與實現(xiàn)