随笔分类 - Linux
摘要:1. local用于函数内部局部变量生命 2. 函数定义框架: rand() { } 3. 执行命令语句用 ``括起来 4. [[]] 用于判断条件 5. (()) 用于计算表达式 6. ${line// /..} 将空格替换成2个.. : aaa bb cc -->aaa....bb......c
阅读全文
摘要:(1)按文件类型查找 # find ./ -type d 目录 # find ./ type f 文件 说明: ./ 是查找范围 (2)按文件名查找 # find ./ -name fullname 完整名称 # find ./ -name .*partname.* 把文件都当目录进行匹配,文件按.
阅读全文
摘要:参考:https://blog.csdn.net/boonya/article/details/83012263 (1)压缩 # tar -zcvf testsh/* testsh.tar.gz 将testsh目录下的所有文件压缩到 testsh.tar.gz 中 -z, --gzip格式打包 -c
阅读全文
摘要:# top (1) # uptime 当前时间 开机了多长时间 活跃用户数 平均负载:1分钟 5分钟 15分钟 平均负载统计:runnable(运行状态的进程) uninterruptable(不可间断状态的进程) cpu core=1,load average=1 ,利用率1 期望不大于3 cpu
阅读全文
摘要:# awk -F : '{print $1}' /etc/passwd | sed ':1;N;s/\n/|/g;t1' ;打印第一列的数据并用|分割替代以前的\n分割 :1 代表打一个标记1 t1 跳转到标记1 N 将读取到的数据追加到模式空间(包含换行符) # sed 's#:x:[0-9]:*
阅读全文
摘要:脚本1: # vi test.sh # !/bin/bash echo $1,$2,$3 echo "文件名" $0 echo "参数变量 "$# echo "all "$* echo "return "$? # bash test.sh 1 2 3
阅读全文
摘要:数组: # a = (a b c d e) # echo ${a[0]} # echo ${a[*]} # echo ${a[@]} b[0] = 1 if 语句: a = 20 b =10 if [ $a -eq $b ]; then echo "=";fi for语句: for loop in
阅读全文
摘要:文件操作: r 4 w2 x1 # ls -l # chmod 777 test.txt # ls -ld test.txt 网络命令: # netstat # netstat -lnpt 性能: # top # ps -aux grep命令: # grep -nv word file.txt ;
阅读全文