脚本

#!/bin/bash

#奇数偶数相加
declare -i evensum=0
declare -i oddsum=0
for I in {1..100};do
if [ $[$I%2] -eq 0 ];then
let evensum+=$I
else
let oddsum+=$I
fi
done
echo evensum is $evensum
echo oddsum is $oddsum

 

批量修改后缀

for file in $(find . -name "*.txt") ; do mv $file ${file%.*}.abc;done   #实测

for file in *.gz; do mv $file ${file%.gz}.zip; done   # 如果用()文件直接被删掉

for file in *#a;   #   test#a
do
mv $file ${file%#*}.aaa.bbb;
done

for file in $(find . -name "*.txt"); do mv $file $(echo $file|sed s/txt$/jpg/); done#实测

for file in $(ls *.jpg);do mv $file $(echo $file|cut -d"." -f1).txt;done #实测

 

ls | grep ".gz$" | awk -F'.' '{print $1}'|xargs -i mv {}.gz {}.zip  #测试未通过

 

posted on 2015-01-01 19:50  寒星12345678999  阅读(129)  评论(0编辑  收藏  举报