xargs和sed联合处理的例子。这个貌似和linux下也不一样。
ls | xargs -I {} sed -i '' 's/balabalabala/\*/g' {}
今天又学到个sed -i 在mac里的in-place替换,跟linux语法不大一样。。
下面是截取关键部分,详见https://mpdaugherty.wordpress.com/2010/05/27/difference-with-sed-in-place-editing-on-mac-os-x-vs-linux/
sed in-place editing (-i) difference on Mac OS X: “undefined label” errors
sed -i '.bak' 's/before/after/' test.txt
leaves you with two files, ‘test.txt‘ and ‘test.txt.bak‘, where ‘test.txt.bak‘ is the original version. Unlike Ubuntu and other linux versions, on OS X, this extension parameter is required. If you really know what you’re doing and don’t want a backup made, you need to provide an empty string ”.
The correct way to run this command on OSX is
sed-i '' 's/before/after/'test.txt
pip3 install tensorflow==2.0.0-beta1 第一次知道可以这样指定版本。哈哈。
while IFS=$'\t' read -r bugId content
The -r tells read that \ isn't special in the input data;
https://stackoverflow.com/questions/9736202/read-tab-separated-file-line-into-array :
Actually -r added by @gniourf_gniourf avoid the expansion of backslashed characters, if doing so %bcould be substituted by %s in the printf format strings cause backslashed scaped characters will be represented as literals. So, use it or not depending on what you really want to do. –slylittl3 Feb 19 '15 at 2:05
---------
The new line character with the echo command is "\n". Taking the following example:
echo -e "This is line 1\nThis is line 2"
Would result in the output
This is line 1This is line 2
The "-e" parameter is important here.
printf "hello\nworld\thaha\n" 可以自动将\n和\t换成相应的换行和tab输出,amazing!
tail -n +2 myfile.txt 从第二行开始读直至末尾
------------------------------------
每次Mac用brew安装时都要update,可烦,后面发现可以不让其update:
HOMEBREW_NO_AUTO_UPDATE=1 brew install xxx
------------------------------------
mac截图各种工具, 具体见下文链接:
http://jingyan.baidu.com/article/76a7e409b50525fc3b6e15ac.html