Mac常用命令

Mac find 去除 “Permission denied” 信息的方法

"用管理员权限执行find"
sudo find / -name "keyword" -print

"丢弃所有错误输出"
find / -name "keyword" -print 2>/dev/null

"过滤 Permission denied 信息"
find / -name "keyword" -print 2>&1 | fgrep -v "Permission denied"

sudo find / -name 微机原理与接口技术.doc -print 2>&1 | fgrep -v "Operation not permitted" | fgrep -v "No such file or directory"

sudo find / -name "info.log" -print 2>&1 | fgrep -v "Operation not permitted" | fgrep -v "No such file or directory"

wangmiao@wangmiaodeMBP Documents % pwd
/Users/wangmiao/Library/Containers/0435340B-24E0-47B2-913F-93876E660017/Data/Documents

# 打开文件夹
open .

Mac终端批量替换字符串:

# -r 表示搜索子目录
# -l 表示输出匹配的文件名

grep -rl '256m' ./ |xargs sed -i "" "s/256m/1g/g"

grep -rl '512m' ./ |xargs sed -i "" "s/512m/1g/g"
上一篇:linux 运行.sh出现 Permission denied 解决办法


下一篇:flutter Cannot open file, path = ‘.../test.jpg‘ (OS Error: Permission denied, errno = 13)