command line pearls 2 - TODO

目录

热身

tee

tee tee.txt

hello tee # Ctrl+ C

cat tee.txt # hello tee

互动: tee和echo有何区别?

man tee
# The tee utility copies standard input to standard output, making a copy in zero or more files

find

find /etc/nginx -name "nginx.conf" # /etc/nginx/nginx.conf

互动: 打印文件树还可以使用什么命令?

man find
# walk a file hierarchy

man tree
# tree - list contents of directories in a tree-like format.

grep

grep -rn console.zhgcloud.com
man grep
# grep, egrep, fgrep, zgrep, zegrep, zfgrep -- file pattern searcher

忘了sudo

:w !sudo tee % > /dev/null
:w !{cmd} # 执行外部命令{cmd} 并将当前缓冲区内容从标准输入传入

sudo tee > /dev/null # 将标准输入输入输出到文件并忽略标准输出

% # %是vim中保存当前编辑文件路径的只读寄存器

PHP扩展

echo 'extension=swoole.so' >> $(php  -i | grep 'Loaded Configuration File' | awk -F '=>' '{print $2}')
php  -i | grep 'Loaded Configuration File' # 筛选php配置信息: Loaded Configuration File => /Users/kevin/.phpbrew/php/php-7.1.15/etc/php.ini

| awk -F '=>' '{print $2}' # 指定'=>'分隔符打印第二个元素

echo 'extension=swoole.so' >> # 将字符串追加输出到指定文件
man awk
# awk - pattern-directed scanning and processing language

替换指定行

添加指定行

参考

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • linux资料总章2.1 1.0写的不好抱歉 但是2.0已经改了很多 但是错误还是无法避免 以后资料会慢慢更新 大...
    数据革命阅读 14,399评论 2 33
  • 一、文件/文件夹管理 ls 列出当前目录文件(不包括隐含文件)ls -a 列出当前目录文件(包括隐含文件)l...
    路痴千行阅读 7,300评论 0 5
  • 一、文件/文件夹管理 ls 列出当前目录文件(不包括隐含文件) ls -a 列出当前目录文件(包括隐含文件) ls...
    小杰的简书阅读 7,412评论 0 45
  • 一、文件/文件夹管理 ls 列出当前目录文件(不包括隐含文件) ls -a 列出当前目录文件(包括隐含文件) ls...
    会飞的鱼Coo阅读 10,047评论 1 23
  • Ubuntu 常用命令大全 查看软件 xxx 安装内容 #dpkg -L xxx 查找软件 #apt-cache ...
    guiwuzhe阅读 7,479评论 0 14

友情链接更多精彩内容