Linux shell常用脚本
2013-10-06 12:53
330 查看
【test】
-n:测试string长度是否是大于0
name='Jack'
if test -n" $name"; then
echo "YES"
else
echo "NO"
fi
输出是YES
【if】
测试string相等
if [ $str = 'abc' ];then
fi
【变量赋值】
myName='liu'
echo $myName
myName='huang'
echo $myName
【Linux 下批量修改后缀名 】
一、rename解决
1. Ubuntu系统下
rename 's/.c/.h/' ./*
把当前目录下的后缀名为.c的文件更改为.h的文件
2. CentOS5.5系统下
rename .c .h *.c
把当前目录下的后缀名为.c的文件更改为.h的文件
二、shell 脚本解决
#!/bin/bash
#http://blog.csdn.net/longxibendi
find ./ -name *.c | while read i
do
echo "$i";
mv $i.c $i.h
done
三、find xargs 解决
find ./ -name"*.c" | awk -F "." '{print $2}' | xargs -i -t mv./{}.c ./{}.h
{},表示awk的{print
$2}的输出值;
该例子把所有.c,该为.h的后缀名;
=====END=====
-n:测试string长度是否是大于0
name='Jack'
if test -n" $name"; then
echo "YES"
else
echo "NO"
fi
输出是YES
【if】
测试string相等
if [ $str = 'abc' ];then
fi
【变量赋值】
myName='liu'
echo $myName
myName='huang'
echo $myName
【Linux 下批量修改后缀名 】
一、rename解决
1. Ubuntu系统下
rename 's/.c/.h/' ./*
把当前目录下的后缀名为.c的文件更改为.h的文件
2. CentOS5.5系统下
rename .c .h *.c
把当前目录下的后缀名为.c的文件更改为.h的文件
二、shell 脚本解决
#!/bin/bash
#http://blog.csdn.net/longxibendi
find ./ -name *.c | while read i
do
echo "$i";
mv $i.c $i.h
done
三、find xargs 解决
find ./ -name"*.c" | awk -F "." '{print $2}' | xargs -i -t mv./{}.c ./{}.h
{},表示awk的{print
$2}的输出值;
该例子把所有.c,该为.h的后缀名;
=====END=====
相关文章推荐
- 常用linux shell脚本记录
- Linux Shell 常用脚本
- linux shell -常用脚本
- linux shell 常用脚本语句语法收集 推荐
- linux shell脚本中,关于test测试和if判断中常用的标志[-eq,gt..]
- Linux Shell脚本与Vim常用操作笔记
- linux shell script 脚本 变量中常用的字符串处理方法
- linux shell -常用脚本
- linux shell脚本常用语句
- linux shell脚本实现:每10秒打印一次系统时间,连续打印10次
- linux shell脚本案例二
- Linux shell脚本功略第2版笔记--第七章
- Oracle 常用技巧和脚本
- Linux Shell常用技巧(目录)
- linux shell脚本案例五:各种数据运算符
- 兼容IE和FF的js脚本代码小结(比较常用)
- Linux Shell常用技巧(一)
- linux shell脚本案例六:结构化程序分支语句
- ORACLE常用脚本总结
- Greasemonkey常用脚本