shell脚本任务总结

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/shytry/article/details/80597031
1、查看定时任务
crontab -e

2、删除文件名含有特殊字符的文件
ls -i   //查看文件的inode号
find ./ -inum 645321 -exec rm -f '{}' \    //找到inode号为12345的文件并执行删除

3、sed -n 4,8p file   //获取文件中的4-8行

4、sed -n 4p file   //获取文件中的第4行

5、sed -n '$=' file  //获取文件file的行数

6、sed -i "s/ /\n/g" filename  //将文件内容换行处理

7.date=$(date + %F)   //获取当前时间

8、使用for循环
for((i=1;i<3;i++))
do 
	....code....
done

9、做判断
str1="111"
str2="222"
result=$(echo "$str1" | grep "$str2")
if [[  "$result"!="" ]];then 
	...code...
fi

10、查看数据库中表占用空间大小
exec sp_spaceused tablename
查看整个数据库占用的空间大小
exec sp_spaceused

猜你喜欢

转载自blog.csdn.net/shytry/article/details/80597031