随笔分类 -  shell

摘要:grep和egrep 第一种形式:grep [option] [pattern] [file1 file2 ...] 第二种形式: command | grep [option] [patern] 选项:option -v 不显示匹配行 grep -v python file -i 搜索时忽略大小写 阅读全文
posted @ 2022-11-08 22:47 phper-liunian 阅读(66) 评论(0) 推荐(0)
摘要:文件查找-find命令 格式:find [路径] [选项] [操作] 选项 -name 根据文件名查找 -iname 根据文件名查找,忽略大小写 -perm 根据文件权限查找 find /etc -perm 777 -prune 该选项可以排除某些查找目录,格式为-path 排除文件 -prune 阅读全文
posted @ 2022-11-05 23:11 phper-liunian 阅读(723) 评论(0) 推荐(0)
摘要:shell函数的定义 # 方法一 function name { command ... command } # 方法二 name() { command ... command } 函数的调用 直接使用函数名调用, 可以将函数名想象成shell的一条命令 函数内部可以使用参数 $1 $2 ... 阅读全文
posted @ 2022-11-05 17:04 phper-liunian 阅读(40) 评论(0) 推荐(0)
摘要:计算字符串长度 ${#string} expr length "$string" string 有空格,则必须加双引号 str="hello world" # ${#string} len=${#string} echo $len 11 # `expr length "$string"` len=` 阅读全文
posted @ 2022-11-01 22:55 phper-liunian 阅读(90) 评论(0) 推荐(0)