`

Shell 自动化部署:杂记

阅读更多

本文以 Ubuntu Server 10.04 为例,下面只是简单记录一些东西,以后会整理成文件发布出来。


1. 使用 tar 工具进行文件压缩与解压缩

# 压缩 test 整个目录
tar -zcvf test.tar.gz ./test

# 解压缩 test.tar.gz 到当前目录的 test 文件中
tar -xzvf test.tar.gz -C ./test

参考自:tar - BackupYourSystemUbuntu 命令技巧之解压缩tar - Shell Scripts GNU tar Manual - 3.4.3 Short Options Cross Reference

 

2. 输出 IP 地址、默认网关及子网掩码

ifconfig eth0 | awk '/Bcast/ {for (i = 1; i <= NF; i++) { n = split($i,x,":"); if (n >= 2 ) { print x[2] } } }'

参考自:查看当前IP地址awk manual网络配置


 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics