Shell脚本一枚
来源:互联网 发布:原生js添加class 编辑:程序博客网 时间:2024/05/23 00:07
脚本如下:
#!/bin/bashdir=$1dir1=""for file in `find $dir -type f`do dir2=${file%/*} name=${file%.*} name1=${name%.*} cd $dir2 gunzip $file if [ -z "$dir1" -o "$dir1" != "$dir2" ];then gzip -c "$name" > "$name1".gz rm -rf "$name" dir1="$dir2" else gzip -c "$name" >> "$name1".gz rm -rf "$name" fidone
需要说明的是:
1. ${file%/*}:拿掉最后一个 / 及其右边的字符串
2. ${file%.*}:拿掉最后一个 . 及其右边的字符串
3. 第一个gzip是将file1压缩成foo.gz,第二个gzip是将file2添加到foo.gz中
gzip -c file1 > foo.gz
gzip -c file2 >> foo.gz
0 0
- Shell脚本一枚
- Shell脚本学习一
- shell脚本学习《一》
- shell脚本学习 一
- 学习Shell脚本[一]
- shell脚本(一)
- 学习shell脚本(一)
- shell脚本编程(一)
- shell脚本学习一
- shell脚本基础知识一
- shell脚本(一)
- shell脚本篇一---shell脚本初步
- Linux shell 脚本实例一
- Linux shell 脚本实例一
- shell基本语法脚本一
- Linux shell 脚本实例一
- Shell (一) 脚本错误检测
- shell脚本学习笔记一
- 利用xinetd进行时间同步
- 如何用perl将表格中不同列的数据进行拼凑,然后将拼凑后的数据用“|”连接在一起
- XMPP创建流程
- 如何编译Zookeeper源码
- (转)J2EE的13种核心技术
- Shell脚本一枚
- 电脑屏幕突然变成绿色的了
- MegaCli 查看raid信息
- Kubernetes集群搭建过程中遇到的问题
- Oracle中如何实现Mysql的两表关联update操作
- MySQL分区表的管理~1
- MySQL分区表的管理~2
- 在mfc中将CView类改为CScrollView类,使得出现下拉条
- MySQL复合分区