写一个脚本 从键盘让用户输入几个文件,脚本能够将此几个文件归档压缩成一个文件
2015-08-25 16:06
281 查看
vim mytar.sh
测试脚本:
本文出自 “小曾” 博客,请务必保留此出处http://zengxin.blog.51cto.com/6098070/1688086
#!/bin/bash # read -p "Three files:" file1 file2 file3 read -p "Destination:" DEST -->指定压缩存放目录及文件名称 read -p "Compress[gzip|bzip2|xz]:" COMP -->输入压缩的格式 case $COMP in gzip) tar -zcf ${DEST}.tar.gz $file1 $file2 $file3 ;; bzip2) tar -jcf ${DEST}.tar.bz2 $file1 $file2 $file3 ;; xz) tar -cf ${DEST}.tar $file1 $file2 $file3 xz ${DEST}.tar ;; *) echo "Unknow." exit 9 ;; esac
测试脚本:
[root@localhost test]# pwd /mnt/test [root@localhost test]#chmod +x mytar.sh [root@localhost test]# ./mytar2.sh Input Three files:test1.txt test2.txt test3.txt Destination:/mnt/test/test Compress[gzip|bzip2|xz]:gzip [root@localhost test]# ls mytar.sh test2.txt test.tar.gz test1.txt test3.txt
本文出自 “小曾” 博客,请务必保留此出处http://zengxin.blog.51cto.com/6098070/1688086
相关文章推荐
- Web.xml配置context-param
- css知多少(4)——解读浏览器默认样式
- UVA297建立完全四叉树统计叶子节点
- 原码, 反码, 补码 详解
- HDU-2189 悼念512汶川大地震遇难同胞――来生一起走
- bootstrap 用法小结
- hdu1525 博弈
- matlab_数据拟合
- Nagios自己编写监控磁盘脚本check_disk
- word文档插入方框加勾
- fileURLWithPath:和URLWithString:的区别
- HDU 2489 Minimal Ratio Tree(枚举组合+最小生成树)
- 工作体会之系统对接
- 在eclipse中配置maven项目
- Item 10:赋值运算符要返回自己的引用 Effective C++笔记
- Item 9:在析构/构造时不要调用虚函数 Effective C++笔记
- 规则引擎 visualrules 开发基础教程【连载2】-- 安装篇
- PAT 1066. Root of AVL Tree (25)
- 用Python操作Mysql
- MFC视频教程(孙鑫)学习笔记1-Windows程序内部运行原理