while ;(创建文20个文件)
cd /etc/services
mkdir -p scripts
vim scirpts .sh
#!/bin/bash
i= 1,dir=/scirpts
while [ $i -lt 21 ]
do touch dir/test$i
let i = $i+1
done
批量改名:
#!/bin/bash
i= 1,dir=/scirpts
while [ $i -lt 21 ]
do mv dir/ test$i alex$i
let i = $i+1
done
删除询问:
for file in dir/*
do rm -i $file
done
首先要创建环境
#!/bin/bash
shopt -s expand _aliases
aliases=ll=''ll -s ''
cd /root /scripts/test/alex
if [ ! -e alex ]
then
/bin/mkdir -p alex
else
echo" ''
fi
path=/root /scripts/test/alex
cd $path
for i ( i=1;i<10;i++)
do
/bin/tuoch alex-$i finshed .jgp
done
变量子串结尾删除最短匹配
for file in ls *.jpg
do
mv $file ${file %fiinshed*}.jpg
done
原文链接:https://www.f2er.com/bash/391926.html