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