Shell
Shell脚本学习
bw-1111
这个作者很懒,什么都没留下…
展开
-
shell中的文本处理工具---grep、sed、awk
1.grepgrep 匹配条件 处理文件grep root passwd #过滤root关键字grep ^root passwd #以root开头grep root$ passwd #以root结尾grep -i root passwd #忽略大小写grep -E "\<root" passwd #root字符之前不能有字符grep -E "root\>" passwd #root字符之后不能有字符grep -E "\<root\>" passwd原创 2020-12-20 15:09:56 · 119 阅读 · 0 评论 -
shell中的变量
1.变量的定义1)变量本身变量就是内存一片区域的地址2)变量存在的意义命令无法操作一直变换的目标用一串固定的字符来表示2.shell脚本中变量的定义方法1)环境级别export a=1在环境关闭后失效2)用户级别vim ~/.bash_profileexport a=13)系统级别vim /etc/profileexport a=2vim /etc/profile.d/westos.shexport b=24)变量名称...原创 2020-12-20 15:10:53 · 64 阅读 · 1 评论 -
shell中的基础命令
1.diff用法;diff xxx yyy输出信息:[num1,num2][a|c|d][num3.num4]num1,num2 #第一个文件的行a #添加c #更改d #删除< #第一个文件中的内容> #第二个文件中的内容num3,num4 #第二个文件中的行常用参数:-b #忽略空格-B #忽略空行-i #忽略大小写-c #显示文件所有内容并标示不同-r #对比目录-u #合并输出2.patchpatch 原文件 补丁文件原创 2020-12-18 11:11:07 · 106 阅读 · 0 评论 -
shell的执行流控制
1.for练习#!/bin/bashfor AA in {1..10}do ping -c1 172.25.254.$AA &>/dev/null && { echo 172.25.254.$AA}done2.while3.until4.if#!/bin/bashCHECK(){ read -p "Please input filename:" FILENAMEif [ "$FILENAME" = "ex原创 2020-12-20 17:16:18 · 72 阅读 · 0 评论