bash脚本实例
来源:互联网 发布:小米手机怎么清楚数据 编辑:程序博客网 时间:2024/05/19 11:17
1、替换目录下文件或单个文件的字符串
#!/bin/bash
search_path=$1
old_str=$2
new_str=$3
grep $old_str -rl $search_path
sed -i "s/$old_str/$new_str/g" `grep $old_str -rl $search_path`
使用方法:./replace.sh "/root/" "stdIO.H" "stdio.h"
2、将标准错误(2)的信息也重定向到文件中
/root/code/test >build.log 2>&1
3、遍历文件的各行,并且忽略某些特殊字符(;)开头的行
for item in `cat $config_path/wsp.cfg $config_path/bsp.cfg | grep -v '^;'`
do
echo $item
done
4、判断环境变量是否设置
if [ -z $WINDRIVER ]
then
export WINDRIVER=/rtools/windriver
fi
5、dos格式(含^M)转换为Unix格式
dos2unix -k .project
6、bash命令执行结果判断
if [ $? -ne 0 ];then exit;fi
7、删除目录下特定的文件
for file in `find $config_path/../$item/PPC32sfgnu -name '*.keep*'`
do
echo $file
rm -f $file
done
----created by braveyly
dos2unix -k .project
6、bash命令执行结果判断
if [ $? -ne 0 ];then exit;fi
7、删除目录下特定的文件
for file in `find $config_path/../$item/PPC32sfgnu -name '*.keep*'`
do
echo $file
rm -f $file
done
----created by braveyly
- bash脚本实例
- Linux bash综合实例之 bash脚本编辑器
- bash 脚本
- bash脚本
- bash脚本
- bash脚本
- bash脚本
- bash脚本
- BASH脚本
- bash脚本
- Bash脚本
- 《高级Bash脚本编程指南》之基本实例讲解
- bash脚本实例-linux性能数据清洗-1
- Bash 实例
- Bash 实例
- Bash 实例
- Bash 实例
- Bash Scripts(Bash 脚本)I
- JDK linux安装
- Using shell scripts for CGI in lighttpd
- 我被老大挨说的equals
- stack 三种含义
- 批量建OU+导用户+启用Exchange邮箱(后补)
- bash脚本实例
- 表驱动的代码实现
- servlet 和 threadlocal 与 web容器
- Apache+tomcat+mod_jk+centos6.2负载均衡集群配置
- 两篇英文文献的架构简析,仅供参考
- 关于ActiveMQ的学习
- Linux vps服务器wdcp控制面板的安装和基本使用
- 结账任务 - 年终结账
- android动画