shell基础
来源:互联网 发布:网络维护基础知识 编辑:程序博客网 时间:2024/06/08 05:25
1.命令
1.常用命令
1.基本
1.文件信息(1)file xxx文件(2)du -a 文件大小/2000 换算 M (mac以1000字节大小为单位)(3)du -ak 文件大小/1000 换算 M (mac以1000字节大小为单位)2.文件内容(1)diff file1 file2 比较并显示两个文件的差异 (2)cat file 输出文件内容(3)head -20 filename 显示文件的最初几行(4)tail -15 filename 显示文件的最后几行3.文件操作(1)cp fileName dir/ 拷贝文件到目录 (2)cp -rf dir1/ dir2/ 拷贝目录到目录 (3)rm -d dir/ 删除目录(4)rm -f file 删除文件(5)makdir newDir 创建文件夹(6)mkdir -p newDir1/newDir2 如果newDir1不存在先创建newDir1在继续创建4.单个命令(1)env 显示当前所有设置过的环境变量(2)history 列出最近执行过的 几条命令及编号5.网络(1)ping www.baidu.com(2)lsof -i:8000 查看端口8000是否被占用(3)kill -9 上面的pid 杀掉上面占用端口的进程6.压缩zip -r ./new.zip dir/ 压缩dir目录成new.zipunzip new.zip 解压new.zipunzip -o new.zip 解压new.zip覆盖同名文件没有提示
2.查找
1.查找文件或文件夹find . -type f -name qian.sh 查找文件find . -type d -name src 查找文件夹find . -type -f -name '*[.jpg|.png]'find . -mtime -1 -a -name *.lua 查找最近一天修改过的.lua文件2.根据内容查找grep -n '内容' filename 指定文件查找grep -r '内容' . 遍历文件夹下所有文件
3.管道xxx
1.xargsfind . -type f | xargs grep "内容" (1)find . -type f 查到的每个结果 xxx/xxx (2)通过管道 (| xargs) 放到 (grep "内容" xxx/xxx) 再次进行过滤2.-exec find . -type f -name *.lua -exec cp -rf {} ../ \; (1)当前路径所有.lua文件拷贝到当前目录上一级目录(../) (2)-exec 后面的 {} 代表前面的输出3.awkls -l | awk '{print $1}' (1) ls -l 打印多列的信息,通过awk过滤只打印第一列的
2.string
3.语句
4.其他
1.数学运算
乘法:echo `expr 2 \* 9`加法:echo `expr 2 + 3`除法:echo `expr 2 / 9`
2.时间
year=`date +%Y` 年 echo `date +%Y` 查看month=`date +%m`day=`date +%d`hour=`date +%H`min=`date +%M``date +%s` 1970到现在秒
阅读全文
0 0
- Shell基础
- Shell 基础
- Shell 基础
- shell基础
- shell 基础
- shell基础
- shell基础
- Shell基础
- shell基础
- shell基础
- shell基础
- Shell基础:
- shell基础
- shell 基础
- shell基础
- shell基础
- shell基础
- shell基础
- 爬虫知识点(scrapy_redis分布式爬虫系统)
- Android Material Design AppBarLayout使用
- UIDatePicker的使用
- idea
- J2EE分布式架构 dubbo+springmvc+mybatis+ehcache+redis分布式架构
- shell基础
- 第八周【项目2
- Linux 基础命令(二)
- CSS特殊字符表
- # 设计模式之----命令模式
- angular4 模块懒加载
- MQTT协议之订阅及发布(使用paho-mqtt-client或mqttv3实现)
- 网络请求数据 Banner轮播
- MemoryModule阅读与PE文件解析(一)