Shell脚本一枚
2016-03-10 15:16
639 查看
脚本如下:
需要说明的是:
1. ${file%/*}:拿掉最后一个 / 及其右边的字符串
2. ${file%.*}:拿掉最后一个 . 及其右边的字符串
3. 第一个gzip是将file1压缩成foo.gz,第二个gzip是将file2添加到foo.gz中
gzip -c file1 > foo.gz
gzip -c file2 >> foo.gz
#!/bin/bash dir=$1 dir1="" 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" fi done
需要说明的是:
1. ${file%/*}:拿掉最后一个 / 及其右边的字符串
2. ${file%.*}:拿掉最后一个 . 及其右边的字符串
3. 第一个gzip是将file1压缩成foo.gz,第二个gzip是将file2添加到foo.gz中
gzip -c file1 > foo.gz
gzip -c file2 >> foo.gz
相关文章推荐
- (转)Shell函数
- Shell最多可以输入多少个参数?
- Unity: CommandRunner.cs (csharp run adb shell on adroid)
- -bash: jps: command not found
- sed详解
- linux下的shell 快捷键
- Shell学习总结
- 远程执行shell
- Shell 脚本之格式化填充
- txt文件转成bin文件shell脚本
- Powershell Scripting Game - March 2016
- shell中的ex命令
- 关于登录shell的小知识
- AIX5安装bash
- [Python2.x] 利用commands模块执行Linux shell命令
- erlang趣事六erlangshell ssh登陆
- 通过 git bash 配置和使用 github
- 插入排序之直接插入排序和Shell排序
- shell脚本并发
- Algrothm_Sort_Shell