现在的位置: 首页 > 综合 > 正文

linux shell 基本命令

2013年08月27日 ⁄ 综合 ⁄ 共 415字 ⁄ 字号 评论关闭

1.不提示删除目录  rm -rf ${dir}

2.rpm 查看并卸载软件

  rpm -qa | grep ${appname}

  rpm -e ${rpmname}

3.数学计算之bc

  echo "3 + 4 - 5 * 5 - 7 " | bc

 echo "3 + 4 - 5 * 5 - 7 " | bc | read myresult

4.查看进程

  ps -ef | grep ${tname}

exp: ps -ef | grep java

        ps -ef | grep mysql

5.启动/停止服务

 service ${servername} start

service ${servername} stop

6.日志监控

  tail -f  $applog

7.文件查找

  grep "${searchcxt}" ${file}

8.文件截取,内容替换,内容提取

 替换 sed 's/abc/cde/g' $file

 替换abc为cde

 sed -n '1,20p' $file > $newfile 1-20行输出到信文件

 sed功能很强大 建议google

 

 

抱歉!评论已关闭.