shell 常用命令
来源:互联网 发布:计算机一级用什么软件 编辑:程序博客网 时间:2024/06/06 12:24
1.sleep 暂停
sleep 1 #暂停1秒2.ip测试
ping -c 1 -w 100 sina.cn
-c: 表示次数,1 为1次
-w: 表示deadline, time out的时间,单位为秒,100为100秒。
3.获取本机IP地址
#/bin/bashifconfig | grep "inet addr:" | awk '{ print $2 }'| sed 's/addr://g'
4.读文件
while read linedo echo $linedone < 0.sh5.获取文件大小
size=`ls -l /etc/passwd | awk '{print $5}'`echo $size
6.查找当前网段内IP用户,重定向到ip.txt文件中
#/bin/basha=1while :do a=$(($a+1)) if test $a -gt 255 then break else echo $(ping -c 1 192.168.0.$a | grep "ttl" | awk '{print $4}'| sed 's/://g') ip=$(ping -c 1 192.168.0.$a | grep "ttl" | awk '{print $4}'| sed 's/://g') echo $ip >> ip.txt fidone
7.杀进程
#/bin/bashpid=`ps -ef | grep '进程相关内容' | grep -v 'grep' | awk '{ print $2}'`if [ -n "$pid" ]; then kill -9 $pidfi8.检查端口号
#!/bin/bashn=1echo "检查xxx服务..."while truedo if test $n -gt 20 then echo "xxx服务启动失败" break fi sleep 5 n=$(($n+1)) port=`netstat -antp | grep "0.0.0.0:8080"` if [ ${#port} -gt 3 ]; then echo "xxx服务已经启动" break; fidone9.获取字符串长度
string="abcd"echo ${#string} #输出 4
10.提取字符串
string="alibaba is a great company"echo ${string:1:4} #输出liba11.查找字符串
string="alibaba is a great company"echo `expr index "$string" is`
12.文件
0 0
- shell常用命令
- shell 常用命令
- shell 常用命令
- shell常用命令
- shell 常用命令
- shell常用命令
- shell常用命令
- shell常用命令
- shell常用命令
- shell常用命令
- shell常用命令
- shell 常用命令
- shell 常用命令
- Shell常用命令
- Shell 常用命令
- shell 常用命令
- shell常用命令
- shell常用命令
- asp判断类型
- The Best Seat in ACM Contest--12年山东省赛(广搜)需要记录数组
- 监控WebLogic9/10的项目部署到Tomcat报[Unsupported protocol: t3]异常的解决办法
- clang LibTooling 的使用 (1)
- 初学Java——ArrayList
- shell 常用命令
- 应该摒弃的七种求职建议
- 浅谈操作系统对内存的管理
- [leetcode][tree] Unique Binary Search Trees II
- struts2工作原理
- 5-14 数据结构啊poi E.splay上的游戏
- UICollectionView详解二:UICollectionViewFlowLayout
- WIFI基本知识整理
- 深入学习微框架:Spring Boot