bash脚本实例
2013-12-03 11:12
363 查看
1、替换目录下文件或单个文件的字符串
使用方法:./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
#!/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` |
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
相关文章推荐
- bash脚本实例-linux性能数据清洗-1
- Linux bash综合实例之 bash脚本编辑器
- Linux bash综合实例之 bash脚本编辑器
- python 捕获 shell/bash 脚本的输出结果实例
- python 捕获 shell/bash 脚本的输出结果实例
- Linux 在Bash脚本中怎么关闭文件描述符的实例
- bash应用实例--交互式进程(如telnet)的自动处理脚本
- bash脚本编程之条件判断、算术运算及实例
- bash部分脚本实例及介绍
- Python实现删除当前目录下除当前脚本以外的文件和文件夹实例
- 伪URL地址引入JavaScript脚本代码实例
- 用C实现的一个Bash脚本
- python脚本实例
- Linux基本功十:bash运算符及启动脚本初步
- Shell 编程--本文结合大量实例阐述如何编写一个shell脚本。
- Mac OS X: 彻底删除GeekTool(bash脚本)
- bash脚本:变量和变量类型
- Bash脚本的两种执行方式
- Bash 实例,第一部分
- 用 Python 替代 Bash 脚本