mac os useful things: scripts shells doc

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# 查看某个工具编译出来的时间
$(which appname) 
 
# 常用for循环
for i in 1 2 3 4 5; do echo "$i"; done; 
 
for((i=140;i<200;i++)); do git tag -d v1.3.$i;done;
 
# 常用读取文件
cat filename | while read line 
do 
    echo $line 
done
 
# "$@"的神奇之处 "$@" 的 参数如果是 “test test” 会直接输出。不会分开
for i in "$@"; do 
 
# mail和mutt的使用
echo hello| mail -s "test" "test@126.com" -f "no-reply@126.com" 
echo | mutt -a syslogs.tar.gz admin@domain.org 
 
# 删除当前目录下面所有 .DS_Store
find $PWD -name ".DS_Store" -exec rm -f {} \;
 
#查看当前文件夹的总大小
du -sh dirname
 
# 使用caffeinate阻止Mac运行屏幕保护和睡眠
caffeinate -t 3600
 
# 使用pkgutil解压PKG文件
pkgutil --expand macx.pkg ~/Desktop/
 
# 使用purge命令释放内存
purge
 
# 使用open命令开启多个相同应用
open -n /Applications/Safari.app/
 
# 不通过App Store更新OS X
sudo softwareupdate -i -a
 
# 将所有下载过的文件列出来
sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'select LSQuarantineDataURLString from LSQuarantineEvent' |more
 
# 使用chflags命令隐藏文件或文件夹,如果你想再次看到文件夹,只需将hidden改为nohidden即可。
chflags hidden ~/Desktop/macx
 
# 创建有密码保护的压缩文件
zip -e protected.zip ~/Desktop/macx.txt