日常工作中用到的tar命令总结

#将指定文件中的文件进行打包,并放到/root目录下

 tar -T mr_zx_url.txt -czvf ~/images.tar.gz

#查看tar文件中的文件数量

 tar -ztvf images.tar.gz |wc -l

linux在使用tab键的时候会对目录名称自动补全,这很方便,也比较常用。
如输入 tomcat/lo 的时候按tab键,命令行会自动生成 tomcat/logs/ ,对于目录,最后会多一个 “/”。这里大家要注意的时候,在使用tar 的–exclude 命令排除打包的时候,不能加“/”,否则还是会把logs目录以及其下的文件打包进去。
错误写法:

tar -zcvf tomcat.tar.gz ?--exclude=tomcat/logs/ --exclude=tomcat/libs/ tomcat

正确写法:

tar -zcvf tomcat.tar.gz --exclude=tomcat/logs --exclude=tomcat/libs tomca
日常工作中用到的tar命令总结
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Scroll to top
0
Would love your thoughts, please comment.x
()
x