❤️💕💕linux常用的网络命令补充,网络知识的补充,Linux网络编程基础。Myblog:http://nsddd.top
[TOC]
[root@k8s-master01 opt]# echo tom{2..100..2}.md
tom2.md tom4.md tom6.md tom8.md tom10.md tom12.md tom14.md tom16.md tom18.md tom20.md tom22.md tom24.md tom26.md tom28.md tom30.md tom32.md tom34.md tom36.md tom38.md tom40.md tom42.md tom44.md tom46.md tom48.md tom50.md tom52.md tom54.md tom56.md tom58.md tom60.md tom62.md tom64.md tom66.md tom68.md tom70.md tom72.md tom74.md tom76.md tom78.md tom80.md tom82.md tom84.md tom86.md tom88.md tom90.md tom92.md tom94.md tom96.md tom98.md tom100.md
[root@k8s-master01 opt]# echo tom{2..100}.md
tom2.md tom3.md tom4.md tom5.md tom6.md tom7.md tom8.md tom9.md tom10.md tom11.md tom12.md tom13.md tom14.md tom15.md tom16.md tom17.md tom18.md tom19.md tom20.md tom21.md tom22.md tom23.md tom24.md tom25.md tom26.md tom27.md tom28.md tom29.md tom30.md tom31.md tom32.md tom33.md tom34.md tom35.md tom36.md tom37.md tom38.md tom39.md tom40.md tom41.md tom42.md tom43.md tom44.md tom45.md tom46.md tom47.md tom48.md tom49.md tom50.md tom51.md tom52.md tom53.md tom54.md tom55.md tom56.md tom57.md tom58.md tom59.md tom60.md tom61.md tom62.md tom63.md tom64.md tom65.md tom66.md tom67.md tom68.md tom69.md tom70.md tom71.md tom72.md tom73.md tom74.md tom75.md tom76.md tom77.md tom78.md tom79.md tom80.md tom81.md tom82.md tom83.md tom84.md tom85.md tom86.md tom87.md tom88.md tom89.md tom90.md tom91.md tom92.md tom93.md tom94.md tom95.md tom96.md tom97.md tom98.md tom99.md tom100.md[root@k8s-master01 opt]# alias
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias xzegrep='xzegrep --color=auto'
alias xzfgrep='xzfgrep --color=auto'
alias xzgrep='xzgrep --color=auto'
alias zegrep='zegrep --color=auto'
alias zfgrep='zfgrep --color=auto'
alias zgrep='zgrep --color=auto'⚡ 使用ubuntu下载zoxide
curl -sS https://webinstall.dev/zoxide | bash
export PATH="/home/$USER/.local/bin:$PATH"
zoxide -V
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
.fzf/install
source ~/.bashrc
#在.bashrc文件最后添加: eval "$(zoxide init bash)",保存移除别名:
unalias zoxide
添加别名:
alias zoxide="z"甚至你可以折磨玩:
alias zoxide='echo 你个煞笔,请不要用这个命令'
::: warning 我们执行的时候的选择
- 顺序执行多条指令:
ls -al; pwd; - 有条件的执行多条指令:
ls -al && pwd上一条执行失败后面不执行 ;ls -al || pwd上一条执行失败,下一条才执行 $?:存储上一次命令的返回结果
:::
::: tip 管道是一种通信机制,通常用于进程间的通信(也可通过socket进行网络通信),它表现出来的形式将前面每一个进程的输出(stdout)直接作为下一个进程的输入(stdin)。
:::
管道命令是一个蛮重要的命令,甚至说你可以玩出很多花样~
管道命令使用|作为界定符号,管道命令与上面说的连续执行命令不一样。
less,more,head,tail...都是可以接受standard input的命令,所以他们是管道命令`
ls,cp,mv并不会接受standard input的命令,所以他们就不是管道命令了。管道命令必须要能够接受来自前一个命令的数据成为standard input继续处理才行。
ls -al /etc | less通过管道将ls -al的输出作为 下一个命令less的输入,方便浏览。
cut -d '分隔字符' -f field // 用于分隔字符
cut -c 字符范围
[参数说明]
-d : 后面接分隔字符,通常与 -f 一起使用
-f : 根据-d 将信息分隔成数段,-f 后接数字 表示取出第几段
-c : 以字符为单位取出固定字符区间的信息grep: 分析一行信息,如果其中有我们需要的信息,就将该行拿出来
grep [-acinv] [--color=auto] '查找字符串' filename
[参数]
-a : 将binary文件以text文件的方式查找数据
-c : 计算找到 '查找字符串'的次数
-i : 忽略大小写的不同
-n : 输出行号
-v : 反向选择,显示没有查找内容的行
--color=auto : 将找到的关键字部分加上颜色显示sort
sort [-fbMnrtuk] [file or stdin]
[参数]
-f :忽略大小写的差异,例如A 与a 视为编码相同
-b :忽略最前面的空格部分
-M :以月份的名字来排序,例如JAN, DEC 等等的排序方法
-n :使用『纯数字』进行排序默认是以文字型态来排序的)
-r :反向排序
-u :就是uniq ,相同的资料中,仅出现一行代表
-t :分隔符号,预设是用[tab] 键来分隔
-k :以那个区间(field) 来进行排序的意思
uniq
uniq [-ic]
[参数]
-i :忽略大小写的不同
-c :进行计数wc
wc [-lwm]
[参数]
-l :仅列出行
-w :仅列出多少字(英文单字)
-m :多少字符**tee:**在数据流的处理过程中将某段信息保存下来,使其既能输出到屏幕又能保存到某一个文件中。
tee [-a] file
[参数]
-a : 以累加的方式,将数据加入file中💡简单的一个案例如下:
last | tee info | cut -d ' ' -f 1
- **tr:**用来删除一段信息当中的文字,或者进行文字信息得替换
tr [-ds] set
[参数]
-d : 删除信息当中的set1这个字符串
-s : 替换掉重复的字符col
col [-xb]
[参数]
-x : 将tab键换成对等的空格键
-b : 在文字内有反斜杠(/)时,仅保留反斜杠最后接的那个字符
col经常被用于将
man page转存为纯文本文件
join: 主要讲两个文件有相同数据的一行,相同字段放在前面
join [-ti12] file1 file2
[参数]
-t : join 默认以空格符分隔数据,并且对比第一个字段的数据 ,如果两个文件相同,则将两条数据连成一行
-i : 忽略大小写的差异
-1 : 说明第一个文件通过那个字段来进行分析
-2 : 说明第二个文件通过那个字段来分析
- paste :直接将两个文件两行贴在一起,中间以[tab]键隔开
paste [-d] file1 file2` `[ 参数]` `-d : 后面可以接分隔字符,默认以[tab]来分隔的` `- : 如果file部分写成-,表示接受standard input数据的意思
栗子11
[root@izuf6i29flb2df231kt91hz /]# paste info info2
root pts/0 112.28.181.159 Sun Jul 1 14:28 still logged in root pts/0 112.28.181.159 Sun Jul 1 14:28 still logged in
root pts/0 112.28.181.159 Sun Jul 1 14:24 - 14:27 (00:03) root pts/0 112.28.181.159 Sun Jul 1 14:24 - 14:27 (00:03)
root pts/0 112.28.181.159 Sun Jul 1 13:19 - 14:24 (01:04) root pts/0 112.28.181.159 Sun Jul 1 13:19 - 14:24 (01:04) expand: 把tab键转为空格键
expand [-t] file[参数]-t: 后面接数字,一般,一个tab可以用8个空格代替,可以自行定义代表几个空格
栗子12
[root@izuf6i29flb2df231kt91hz /]# cat info | expand -3 info
root pts/0 112.28.181.159 Sun Jul 1 14:28 still logged in
root pts/0 112.28.181.159 Sun Jul 1 14:24 - 14:27 (00:03)
root pts/0 112.28.181.159 Sun Jul 1 13:19 - 14:24 (01:04)
root tty1 Sun Jul 1 12:46 still logged insplit:顾名思义,讲一个大文件依据文件大小或行数切割成为小文件
split [-bl] file prefix` `[参数]` `-b : 后面可接欲切割文件的大小,可加单位,例如b,k,m等` `-l : 以行数来进行切割` `PREFIX : 代表前导符,可作为切割文件的前导文字
-
✴️版权声明 © :本书所有内容遵循CC-BY-SA 3.0协议(署名-相同方式共享)©
