{"id":13452897,"url":"https://github.com/oldratlee/useful-scripts","last_synced_at":"2025-04-08T21:18:40.920Z","repository":{"id":7402220,"uuid":"8732561","full_name":"oldratlee/useful-scripts","owner":"oldratlee","description":"🐌 useful scripts for making developer's everyday life easier and happier, involved java, shell etc.","archived":false,"fork":false,"pushed_at":"2024-09-03T07:33:58.000Z","size":1784,"stargazers_count":7400,"open_issues_count":9,"forks_count":2815,"subscribers_count":411,"default_branch":"dev-3.x","last_synced_at":"2025-04-02T05:43:11.458Z","etag":null,"topics":["bash","developers-everyday-life","java","option-parser","python","script","shell","show-busy-java-threads","show-duplicate-java-classes","terminal","useful-scripts"],"latest_commit_sha":null,"homepage":"https://github.com/oldratlee/useful-scripts","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oldratlee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-03-12T16:28:38.000Z","updated_at":"2025-04-01T06:42:38.000Z","dependencies_parsed_at":"2023-01-13T14:21:41.349Z","dependency_job_id":"a5794bff-84c5-47fa-ab3a-2c0416ba5ed5","html_url":"https://github.com/oldratlee/useful-scripts","commit_stats":{"total_commits":559,"total_committers":15,"mean_commits":"37.266666666666666","dds":0.04114490161001794,"last_synced_commit":"dccc9571fb2423fc4c4e16f45d3a51ddeeaf45dc"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oldratlee%2Fuseful-scripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oldratlee%2Fuseful-scripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oldratlee%2Fuseful-scripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oldratlee%2Fuseful-scripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oldratlee","download_url":"https://codeload.github.com/oldratlee/useful-scripts/tar.gz/refs/heads/dev-3.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247927406,"owners_count":21019526,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","developers-everyday-life","java","option-parser","python","script","shell","show-busy-java-threads","show-duplicate-java-classes","terminal","useful-scripts"],"created_at":"2024-07-31T08:00:26.544Z","updated_at":"2025-04-08T21:18:40.904Z","avatar_url":"https://github.com/oldratlee.png","language":"Shell","readme":"# \u003cdiv align=\"center\"\u003e\u003ca href=\"#dummy\"\u003e\u003cimg src=\"https://github.com/oldratlee/useful-scripts/assets/1063891/990d7ab3-1a84-4024-b1c6-4c8d441dcfc6\" alt=\"🐌 useful-scripts\"\u003e\u003c/a\u003e\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/oldratlee/useful-scripts/actions/workflows/ci.yaml\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/oldratlee/useful-scripts/ci.yaml?branch=dev-3.x\u0026logo=github\u0026logoColor=white\" alt=\"Github Workflow Build Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/oldratlee/useful-scripts/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/release/oldratlee/useful-scripts.svg\" alt=\"GitHub release\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.apache.org/licenses/LICENSE-2.0.html\"\u003e\u003cimg src=\"https://img.shields.io/github/license/oldratlee/useful-scripts?color=4D7A97\u0026logo=apache\" alt=\"License\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/oldratlee/useful-scripts/stargazers\"\u003e\u003cimg src=\"https://img.shields.io/github/stars/oldratlee/useful-scripts?style=flat\" alt=\"GitHub Stars\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/oldratlee/useful-scripts/fork\"\u003e\u003cimg src=\"https://img.shields.io/github/forks/oldratlee/useful-scripts?style=flat\" alt=\"GitHub Forks\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/oldratlee/useful-scripts/issues\"\u003e\u003cimg src=\"https://img.shields.io/github/issues/oldratlee/useful-scripts\" alt=\"GitHub issues\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/oldratlee/useful-scripts/graphs/contributors\"\u003e\u003cimg src=\"https://img.shields.io/github/contributors/oldratlee/useful-scripts\" alt=\"GitHub Contributors\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/oldratlee/useful-scripts\"\u003e\u003cimg src=\"https://img.shields.io/github/repo-size/oldratlee/useful-scripts\" alt=\"GitHub repo size\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n🐌 useful scripts for making developer's everyday life easier and happier, involved java, shell etc.\n\n👉 平时有用的手动操作做成脚本，以便捷地使用，让开发的日常生活更轻松些。 💕\n\n欢迎 👏 💖\n\n- 提问，[提交 Issue](https://github.com/oldratlee/useful-scripts/issues/new)\n- 分享平时自己常用但没有写成脚本的功能（即需求、想法），[提交Issue](https://github.com/oldratlee/useful-scripts/issues/new)\n- 优化改进，[Fork 后提通过 Pull Request 贡献代码](https://github.com/oldratlee/useful-scripts/fork)\n- 提供的自己好用脚本实现，[Fork 后提通过 Pull Request 提供](https://github.com/oldratlee/useful-scripts/fork)\n\n本仓库的脚本（如`Java`相关脚本）在阿里等公司（如随身云，见[`awesome-scripts`仓库](https://github.com/Suishenyun/awesome-scripts)说明）的线上生产环境部署使用。\n\n如果你的公司有部署使用，欢迎使用通过 [Issue：who's using | 用户反馈收集](https://github.com/oldratlee/useful-scripts/issues/96) 告知，方便互相交流反馈～ 💗\n\n\u003ca href=\"#dummy\"\u003e\u003cimg src=\"https://github.com/oldratlee/useful-scripts/assets/1063891/82f2d184-ca16-4c37-b053-07f21fd8aef1\" alt=\"repo-icon\" width=\"20%\" align=\"right\" /\u003e\u003c/a\u003e\n\n----------------------\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n- [🔰 快速下载\u0026使用](#-%E5%BF%AB%E9%80%9F%E4%B8%8B%E8%BD%BD%E4%BD%BF%E7%94%A8)\n- [📚 使用文档](#-%E4%BD%BF%E7%94%A8%E6%96%87%E6%A1%A3)\n    - [☕ `Java`相关脚本](#-java%E7%9B%B8%E5%85%B3%E8%84%9A%E6%9C%AC)\n    - [🐚 `Shell`相关脚本](#-shell%E7%9B%B8%E5%85%B3%E8%84%9A%E6%9C%AC)\n- [🎓 Developer Guide](#-developer-guide)\n    - [🎯 面向开发者的目标](#-%E9%9D%A2%E5%90%91%E5%BC%80%E5%8F%91%E8%80%85%E7%9A%84%E7%9B%AE%E6%A0%87)\n        - [关于`Shell`脚本](#%E5%85%B3%E4%BA%8Eshell%E8%84%9A%E6%9C%AC)\n    - [🚦 开发约定](#-%E5%BC%80%E5%8F%91%E7%BA%A6%E5%AE%9A)\n    - [📚 `Shell`学习与开发的资料](#-shell%E5%AD%A6%E4%B9%A0%E4%B8%8E%E5%BC%80%E5%8F%91%E7%9A%84%E8%B5%84%E6%96%99)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n----------------------\n\n🔰 快速下载\u0026使用\n----------------------\n\n```bash\nsource \u003c(curl -fsSL https://raw.githubusercontent.com/oldratlee/useful-scripts/release-3.x/test/self-installer.sh)\n```\n\n更多下载\u0026使用方式，参见[下载使用](docs/install.md)。\n\n📚 使用文档\n----------------------\n\n### ☕ [`Java`相关脚本](docs/java.md)\n\n1. [show-busy-java-threads](docs/java.md#-show-busy-java-threads)  \n   用于快速排查`Java`的`CPU`性能问题(`top us`值过高)，自动查出运行的`Java`进程中消耗`CPU`多的线程，并打印出其线程栈，从而确定导致性能问题的方法调用。\n1. [show-duplicate-java-classes](docs/java.md#-show-duplicate-java-classes)  \n   找出`jar`文件和`class`目录中的重复类。用于排查`Java`类冲突问题。\n1. [find-in-jars](docs/java.md#-find-in-jars)  \n   在目录下所有`jar`文件里，查找类或资源文件。\n\n### 🐚 [`Shell`相关脚本](docs/shell.md)\n\n`Shell`使用加强：\n\n1. [c](docs/shell.md#-c)  \n   原样命令行输出，并拷贝标准输出到系统剪贴板，省去`CTRL+C`操作，优化命令行与其它应用之间的操作流。\n1. [coat and taoc](docs/shell.md#-coat)  \n   彩色`cat`/`tac`出文件行，方便人眼区分不同的行。\n1. [a2l](docs/shell.md#-a2l)  \n   按行彩色输出参数，方便人眼查看。\n1. [uq](docs/shell.md#-uq)  \n   不重排序输入完成整个输入行的去重。相比系统的`uniq`命令加强的是可以跨行去重，不需要排序输入。\n1. [ap and rp](docs/shell.md#-ap-and-rp)  \n   批量转换文件路径为绝对路径/相对路径，会自动跟踪链接并规范化路径。\n1. [cp-into-docker-run](docs/shell.md#-cp-into-docker-run)  \n   一个`Docker`使用的便利脚本。拷贝本机的执行文件到指定的`docker container`中并在`docker container`中执行。\n1. [tcp-connection-state-counter](docs/shell.md#-tcp-connection-state-counter)  \n   统计各个`TCP`连接状态的个数。用于方便排查系统连接负荷问题。\n1. [xpl and xpf](docs/shell.md#-xpl-and-xpf)  \n   在命令行中快速完成 在文件浏览器中 打开/选中 指定的文件或文件夹的操作，优化命令行与其它应用之间的操作流。\n\n`Shell`开发/测试加强：\n\n1. [echo-args](docs/shell.md#-echo-args)  \n   输出脚本收到的参数，在控制台运行时，把参数值括起的括号显示成 **红色**，方便人眼查看。用于调试脚本参数输入。\n1. [console-text-color-themes.sh](docs/shell.md#-console-text-color-themessh)  \n   显示`Terminator`的全部文字彩色组合的效果及其打印方式，用于开发`Shell`的彩色输出。\n1. [parseOpts.sh](docs/shell.md#-parseoptssh)  \n   命令行选项解析库，加强支持选项有多个值（即数组）。\n\n## 🎓 Developer Guide\n\n为用户提供有用的功能，当然是这个库的首要的价值体现和存在理由。\n\n但作为一个**开源**项目，每个人都可以看到源码实现，这个库或许能做得更多。\n\n### 🎯 面向开发者的目标\n\n- 将`Shell/Bash`作为线上生产环境使用的专业编程语言。\n- 期望体现`Shell/Bash`脚本 生产环境级的严谨开发方式与最佳实践，进而有可能示例与改善在生产环境中`Shell`脚本的质量状况。\n\nPS：\n\n- 虽然上面是自己期望的目标，但自己在`Shell`语言上一定会有很多理解和使用上的问题、在这些实现脚本中也会很多需要的改进，可以一起学习、讨论与实践～ 💕\n- 这个库中脚本的实现也有使用`Python`。\n\n#### 关于`Shell`脚本\n\n命令行（`CLI`）几乎是每个程序员每天都在使用的工具。相比图形界面工具（`GUI`），命令行有着自己不可替代的便利性和优越性。\n\n命令行里写出来其实就是`Shell`脚本，可以说每个开发者会写`Shell`脚本（或多或少）。在生产环境的功能实现中，也常会看到`Shell`脚本（虽然不如主流语言那么常见）。\n\n可能正因为上面所说的`Shell`脚本的便利性和大众性：\n\n- `Shell`脚本有不少是顺手实现的（包括生产环境用的`Shell`脚本）；\n- `Shell`脚本的实现常常可能质量不高，会引发线上严重的故障。\n\n### 🚦 开发约定\n\n在这个库中的`Shell`脚本：\n\n- 统一使用`Bash 3.2+`；\n- 面向生产环境，尽可能使用严谨安全的开发方式。\n\n`Shell`用`Bash`的原因是：\n\n- 目前仍然是主流的`Shell`，并且在不同环境基本上都缺省部署了。\n- 在[`Google`的`Shell`风格指南](https://zh-google-styleguide.readthedocs.io/en/latest/google-shell-styleguide/background.html#shell)中，明确说到了：`Bash`是**唯一**被允许执行的`shell`脚本语言。\n- 统一用`Bash`，可以避免不同`Shell`之间差异所带来的风险与没有收益的复杂性。\n    - 有大量的`Shell`实现，`sh`、`bash`、`zsh`、`fish`、`csh`、`tcsh`、`ksh`、`ash`、`dash`……\n    - 不同的`Shell`有各种差异，深坑勿入。\n- 个人系统学习过的是`Bash`，比较理解熟悉。\n\nPS: 虽然交互`Shell`个人已经使用`Zsh` + [`oh-my-zsh`](https://ohmyz.sh/)，但在严谨的`Shell`脚本开发时还是使用`Bash`。\n\n### 📚 `Shell`学习与开发的资料\n\n\u003e 更多资料参见 [子文档](docs/developer-guide.md)。\n\n- 🛠️ 开发规范与工具\n    - [`Google Shell Style Guide`](https://google.github.io/styleguide/shell.xml) | [中文版](https://zh-google-styleguide.readthedocs.io/en/latest/google-shell-styleguide/contents.html)\n    - [`koalaman/shellcheck`](https://github.com/koalaman/shellcheck): `ShellCheck`, a static analysis tool for shell scripts\n    - [`mvdan/sh(shfmt)`](https://github.com/mvdan/sh): `shfmt` formats shell programs\n- 👷 **`Bash/Shell`最佳实践与安全编程**文章\n    - [Use the Unofficial Bash Strict Mode (Unless You Looove Debugging)](http://redsymbol.net/articles/unofficial-bash-strict-mode/)\n    - Bash Pitfalls: 编程易犯的错误 - 团子的小窝：[Part 1](http://kodango.com/bash-pitfalls-part-1) | [Part 2](http://kodango.com/bash-pitfalls-part-2) | [Part 3](http://kodango.com/bash-pitfalls-part-3) | [Part 4](http://kodango.com/bash-pitfalls-part-4) | [英文原文：Bash Pitfalls](http://mywiki.wooledge.org/BashPitfalls)\n    - [不要自己去指定`sh`的方式去执行脚本](https://github.com/oldratlee/useful-scripts/issues/57#issuecomment-326485965)\n- 🎶 **Tips**\n    - [让你提升命令行效率的 Bash 快捷键 【完整版】](https://linuxtoy.org/archives/bash-shortcuts.html)  \n      补充：`ctrl + x, ctrl + e` 就地打开文本编辑器来编辑当前命令行，对于复杂命令行特别有用\n    - [应该知道的Linux技巧 | 酷 壳 - CoolShell](https://coolshell.cn/articles/8883.html)\n    - 简洁的 Bash Programming 技巧 - 团子的小窝：[Part 1](http://kodango.com/simple-bash-programming-skills) | [Part 2](http://kodango.com/simple-bash-programming-skills-2) | [Part 3](http://kodango.com/simple-bash-programming-skills-3)\n- 💎 **系统学习** — 看文章、了解Tips完全不能替代系统学习才能真正理解并专业开发！\n    - [《Bash Pocket Reference》](https://book.douban.com/subject/26738258/)  \n      力荐！说明简单直接结构体系的佳作，专业`Bash`编程必备！且16年的第二版更新到了新版的`Bash 4`\n    - [《学习bash》](https://book.douban.com/subject/1241361/) 上面那本的展开版\n    - 官方资料\n        - [`bash man`](https://manned.org/bash) | [中文版](http://ahei.info/chinese-bash-man.htm)\n        - [Bash Reference Manual - gnu.org](http://www.gnu.org/software/bash/manual/) | [中文版](https://yiyibooks.cn/Phiix/bash_reference_manual/bash%E5%8F%82%E8%80%83%E6%96%87%E6%A1%A3.html)  \n          Bash参考手册，讲得全面且有深度，比如会全面地讲解不同转义的区别、命令的解析过程，这有助统一深入的方式认识Bash整个执行方式和过程。这些内容在其它书中往往不会讲（因为复杂难于深入浅出的讲解），但却一通百通的关键。\n    - [Advanced Bash-Scripting Guide](https://hangar118.sdf.org/p/bash-scripting-guide/index.html): An in-depth exploration of the art of shell scripting.\n    - [命令行的艺术 - `jlevy/the-art-of-command-line`](https://github.com/jlevy/the-art-of-command-line/blob/master/README-zh.md)\n    - [`awesome-lists/awesome-bash`](https://github.com/awesome-lists/awesome-bash): A curated list of delightful Bash scripts and resources.\n    - [`alebcay/awesome-shell`](https://github.com/alebcay/awesome-shell): A curated list of awesome command-line frameworks, toolkits, guides and gizmos.\n    - 更多书籍参见个人整理的[书籍豆列 **_`Bash/Shell`_**](https://www.douban.com/doulist/1779379/)\n","funding_links":[],"categories":["Shell","其他","HarmonyOS","bash","Shell-Scripts","Uncategorized"],"sub_categories":["Windows Manager","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foldratlee%2Fuseful-scripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foldratlee%2Fuseful-scripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foldratlee%2Fuseful-scripts/lists"}