1.添加命令到环境变量
vi ~/.bash_profile
增加一行
export path=$path:/path1:/path2:/pahtN
保存退出
2.增加显示文件命令ls,以列表,属性,颜色,文件特征显示文件。
vi ~/.bash_profile
增加一行
alias ll="ls -laGF"
保存退出
执行立即生效
source ~/.bash_profile
3.定时任务
sudo crontab -e
30 21 * * * /sbin/shutdown -h +0
21 14 * * * /sbin/shutdown -h +0
4.curl使用代理访问网络.
curl -x 192.168.0.1:808 -U user:password -p www.baidu.com
5.打包文件夹,并过滤掉特定文件,比如备份的时候.
tar --exclude *.dmg --exclude pdf2/dist --exclude pdf2/build -czf test.tar.gz pdf2
tar -tf test.tar.gz pdf2
tar -xf test.tar.gz
# 打包 /home/xxx 目录下的 xxx_resources目录,tar.gz里没有绝对路径,即没有/home/xxx目录,tar.gz里的根目录是xxx_resources
tar --exclude logs -czf xxx_resources.tar.gz -C /home/xxx xxx_resources/.
# 不解压查看压缩包目录,有gzip压缩的。
tar -tzf X.tar.gz
# 无gzip压缩的
tar -tf X.tar.gz
-- 打包test文件夹为test.tar.gz,排除.dmg后缀名的文件.
-- 列举文件内容
-- 解压。
6.创建软链接
ln -s /Volumes/BOOTCAMP/参考/iOS .
本文介绍了如何通过修改~/.bash_profile来定制你的shell环境,包括添加环境变量、定义别名实现增强版ls命令,设置定时任务,以及利用curl通过代理访问网页等内容。此外还详细讲解了tar命令的各种实用用法。
795





