几个bash代码
来源:互联网 发布:招商重工 软件著作权 编辑:程序博客网 时间:2024/06/06 09:39
一、编译文件夹中的文件
#!/bin/bash#递归遍历jar 包copyfile() { echo '$1',$1,' $2',$2 for item in `ls $1` do item_path=$1"/"$item if [ -d $item ]; then echo 'dir:'$item_path cd $item copyfile $item_path $2 cd .. elif [ -f $item ]; then echo 'file:'$item_path ret=`echo $item | grep "\.jar" |grep -v 'sha1' |grep -v "[0-9]\.jar"` if [ ! "$ret" = "" ]; then cp $item_path $2 fi fi done}cd /data/maven-repositorycopyfile /data/maven-repository /trunk/jarpackage
二、 获取日期格式
today=`date`year=`date -d '3 days ago' +%F|cut -d "-" -f 1`month=`date -d '3 days ago' +%F|cut -d "-" -f 2`day=`date -d '3 days ago' +%F|cut -d "-" -f 3`day_7=`date -d '7 days ago' +%F|cut -d "-" -f 3`day_1=`date -d '1 days ago' +%F|cut -d "-" -f 3`date -d "now" +"%Y%m%d" #20130702#echo `date '+%Y-%m-%d'` - $hst >> /root/wap/plog_clear.log#rm -rf /data/server_log/push-server/*.log.$year-$month-$day_7*rm -rf /data/web_log/log/xoa/flashscreen/*.log.$year-$month-"$day_1"
三、杀进程
if [ $# -ne 1 ]; then echo 'parameters error' exit 1fipids=`ps -ef |grep $1 | grep -v grep |grep -v 'Controller'| grep 'icebox' |awk '{print $2}'`echo $pidsecho "---------------------"for pid in $pidsdo kill -9 $pid echo "pid: $pid killed"done
四、循环处理字符串
SERV=("10.3.24.21 10.3.24.22 10.3.24.23 10.3.24.24 10.7.16.25 10.7.16.26 ")for i in ${SERV[@]}; do echo $i# /usr/bin/ssh ${FLAG} root@${i} "echo '$2@XIAONEI.OPI.COM' >> ~/.k5login"done
五、输入
while [ -n "$1" ]; docase $1 in -h) help;shift 1;; # function help is called -type) type=$2;shift 1;; # variable opt_f is set -time) startTime=$2;endTime=$3;shift 3;; # -l takes an argument -> shift by 2 *) break;;esacdoneecho "type is $type"echo "start is $startTime. end is $endTime"
- 几个bash代码
- Bash几个特点
- 学几个bash快捷键
- 学几个bash快捷键
- 记住几个bash快捷键
- 几个bash快捷键
- 几个bash shell脚本
- 几个小型 bash 例子
- 几个bash配置文件的说明
- bash的几个初始化文件
- bash的几个特别字符
- bash的几个初始化文件
- Bash常用的几个配置文件
- 几个代码
- BASH代码Refine实例
- [bash]: 删除代码注释
- bash 常用代码片段
- bash小代码
- 利用XRDP远程登陆linux系统
- 第九周作业
- 数据结构之堆
- POCO库中文编程参考指南(10)如何使用TCPServer框架?
- 编程思维训练(一)
- 几个bash代码
- WinRT
- 如何成为一个技术“牛人”
- OpenGL Win764位导入库
- 别把自己变成了“二等公民”
- android实现分享给好友功能
- spring 定时任务(2)
- 嵌入式软件开发之我见
- 逃不掉的是回忆,忘不了的是曾经:伤感日志