Linux高频命令
1. sed字符替换
- 用法;
sed 's/原字符串/替换字符串/'
单引号里面,s表示替换,三根斜线中间是替换的样式,特殊字符需要使用反斜线”\”进行转义。 - 单引号” ‘ ’”是没有办法用反斜线”\”转义的,这时候只要把命令中的单引号改为双引号就行了,格式如下:
# 要处理的字符包含单引号 sed "s/原字符串包含'/替换字符串包含'/" - 可以在末尾加g替换每一个匹配的关键字,否则只替换每行的第一个,例如:
# 替换所有匹配关键字 sed 's/原字符串/替换字符串/g' - sed处理过的输出是直接输出到屏幕上的,使用参数”i”直接在文件中替换。
sed -i 's/原字符串/替换字符串/g' filename - 同时执行多个替换规则
sed 's/^/添加的头部&/g;s/$/&添加的尾部/g'
2. cat、tac、nl三者的区别
- cat file
- 对文件的内容顺序打印输出
- tac file
- 与cat相反,倒序打印输出
- nl file
- 顺序输出,同时加上行号
实例:
cf055001b8e3:/# touch testfile
cf055001b8e3:/# vi testfile
cf055001b8e3:/# cat testfile
LINUX!
Linux is a free unix-type opterating system.
This is a linux testfile!
Linux test
Google
Taobao
Runoob
Tesetfile
Wiki
cf055001b8e3:/# tac testfile
Wiki
Tesetfile
Runoob
Taobao
Google
Linux test
This is a linux testfile!
Linux is a free unix-type opterating system.
LINUX!
cf055001b8e3:/# nl testfile
1 LINUX!
2 Linux is a free unix-type opterating system.
3 This is a linux testfile!
4 Linux test
5 Google
6 Taobao
7 Runoob
8 Tesetfile
9 Wiki
linux 查找动态链接库的位置
ldconfig -p |grep lib**
下载curl,wget
curl url
等于
wget -qO- url
df -h 和du -sh的用法
都是关于空间容量的命令
查询总磁盘占用率利用率和总空间
df -h

du -sh # 后面可以跟./路径,查询磁盘占用空间


浙公网安备 33010602011771号