Linux 命令行笔记

遍历目录查找内容

grep -rnw '/path/to/somewhere/' -e 'pattern'
  • -r 或 -R 表示遍历
  • -n 显示行号
  • -w 全文匹配
  • -l (小写 L) 只显示文件名
  • -e 匹配的表达式

参考:How do I find all files containing specific text on Linux? – Stack Overflow

复制多个目录

cp -r d1 d2 d-* dist/

查找磁盘占用

ubuntu@VM-16-15-ubuntu:~$ sudo du -h --max-depth=1 /var/lib/docker/volumes | sort -h
8.0K	/var/lib/docker/volumes/7e6264b4649948452587e6b562dae6a5881d17ba0254eefb6a98e32dae35f593
8.0K	/var/lib/docker/volumes/e3a990377c6c214dd7b8c45807c8f63319988b2a29c4e58d13c0445da3e2e7d5
8.0K	/var/lib/docker/volumes/sentry-self-hosted_sentry-kafka-log
8.0K	/var/lib/docker/volumes/sentry-self-hosted_sentry-secrets
12K	/var/lib/docker/volumes/373a3159029b89230c64a7dc74633a48f29fa5a10dd7fee57a16318d659e76a7
12K	/var/lib/docker/volumes/sentry-self-hosted_sentry-smtp-log
28K	/var/lib/docker/volumes/sentry-self-hosted_sentry-nginx-cache
36K	/var/lib/docker/volumes/sentry-symbolicator
92K	/var/lib/docker/volumes/sentry-self-hosted_sentry-smtp
144K	/var/lib/docker/volumes/sentry-self-hosted_sentry-zookeeper-log
368K	/var/lib/docker/volumes/sentry-zookeeper
712K	/var/lib/docker/volumes/sentry-data
1.8M	/var/lib/docker/volumes/sentry-redis
814M	/var/lib/docker/volumes/sentry-self-hosted_sentry-clickhouse-log
1.6G	/var/lib/docker/volumes/sentry-clickhouse
14G	/var/lib/docker/volumes/sentry-postgres
16G	/var/lib/docker/volumes/sentry-kafka
31G	/var/lib/docker/volumes

如果您觉得文章内容对您有用,不妨支持我创作更多有价值的分享:


已发布

分类

来自

评论

欢迎吐槽,共同进步

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据