Linux-文件分隔split和总结

7.Shell

本章同步视频:https://edu.51cto.com/sd/e4874

7.6.6 分割命令: split

1.split - split a file into piecesshell

(1)语法bash

[dmtsai@study ~]$ split [-bl] file PREFIXide

选项与参数:学习

-b  :后面可接欲分割成的档案大小,可加单位,例如 b, k, m 等;spa

-l  :以行数来进行分割。orm

PREFIX :表明前导符的意思,可做为分割档案的前导文字。视频

(2)按行切割接口

[root@localhost tmp]# wc -l last 内存

25 last      #文件有25行get

[root@localhost tmp]# split -l 5 last     #每一个文件占5行

[root@localhost tmp]# ls x*

xaa  xab  xac  xad  xae      #拆分红5个文件

(3)按大小切割

[root@localhost tmp]# wc -c last

147 last    #文件大小为147字节

[root@localhost tmp]# split -b 15 last     #每一个文件占15字节

[root@localhost tmp]# ls x*

xaa  xab  xac  xad  xae  xaf  xag  xah  xai  xaj     #10个文件

(4)指定拆分后文件名

[root@localhost tmp]# split -l 5 last last_

#指定拆分后文件名前缀为last_

[root@localhost tmp]# ls last*

last  last_aa  last_ab  last_ac  last_ad  last_ae

(5)用数字作后缀

[root@localhost tmp]# split -l 5 -d last last_

[root@localhost tmp]# ls last*

last     last_00  last_01  last_02  last_03  last_04

本章同步视频:https://edu.51cto.com/sd/e4874

7.7 总结

l  因为核心在内存中是受保护的区块,所以咱们必需要透过『 Shell 』将咱们输入的指令与 Kernel 沟通,好让 Kernel 能够控制硬件来正确无误的工做

l  学习 shell 的缘由主要有:文字接口的 shell 在各大 distribution 都同样;远程管理时文字接口速度较快; shell 是管理 Linux 系统很是重要的一环,由于 Linux 内不少控制都是以 shell 撰写的。

l  系统合法的 shell 均写在 /etc/shells 档案中;

l  用户默认登入取得的 shell 记录于 /etc/passwd 的最后一个字段;

l  bash 的功能主要有:命令编修能力;命令与档案补全功能;命令别名设定功能;工做控制、前景背景控制;程序化脚本;通配符

l  type 能够用来找到执行指令为什么种类型,亦可用于与 which 相同的功能;

l  变量就是以一组文字或符号等,来取代一些设定或者是一串保留的数据

l  变量主要有环境变量与自定义变量,或称为全局变量与局部变量

l  使用 env 与 export 可观察环境变量,其中 export 能够将自定义变量转成环境变量;

l  set 能够观察目前 bash 环境下的全部变量;

l  $? 亦为变量,是前一个指令执行完毕后的回传值。在 Linux 回传值为 0 表明执行成功;

l  可用 read 让用户由键盘输入变量的值

l  bash 的配置文件主要分为 login shell 与 non-login shell。login shell 主要读取 /etc/profile 与 ~/.bash_profile, non-login shell 则仅读取 ~/.bashrc

l  通配符主要有: *, ?, [] 等等

l  数据流重导向透过 >, 2>, < 之类的符号将输出的信息转到其余档案或装置去;

l  连续命令的下达可透过 ; && || 等符号来处理

l  管线命令的重点是:『管线命令仅会处理 standard output,对于 standard error output 会予以忽略』 『管线命令必需要可以接受来自前一个指令的数据成为 standard input 继续处理才行。』

l  本章介绍的管线命令主要有:cut, grep, sort, wc, uniq, tee, tr,  join, paste, split 等。

本章同步视频:https://edu.51cto.com/sd/e4874

相关文章
相关标签/搜索