{"id":20482092,"url":"https://github.com/uk0/she","last_synced_at":"2026-06-08T10:01:19.717Z","repository":{"id":183856897,"uuid":"670872380","full_name":"uk0/she","owner":"uk0","description":null,"archived":false,"fork":false,"pushed_at":"2023-07-26T04:14:03.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-29T21:49:35.952Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uk0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-26T03:15:31.000Z","updated_at":"2023-07-26T03:38:42.000Z","dependencies_parsed_at":"2023-07-26T06:17:34.980Z","dependency_job_id":null,"html_url":"https://github.com/uk0/she","commit_stats":null,"previous_names":["uk0/she"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/uk0/she","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uk0%2Fshe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uk0%2Fshe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uk0%2Fshe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uk0%2Fshe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uk0","download_url":"https://codeload.github.com/uk0/she/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uk0%2Fshe/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34057158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-15T16:11:27.576Z","updated_at":"2026-06-08T10:01:19.658Z","avatar_url":"https://github.com/uk0.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"## she\n\n\u003e 记录一些小脚本，慢慢更新之前的硬盘坏了好多脚本都无了，现在慢慢整理。\n\n### 脚本列表\n\n__cpuinfo.sh__ 这个脚本将打印出过去一秒的 CPU 使用量和空闲量，单位为核心数，结果保留两位小数。\n\u003cbr\u003e\n__group_by_type.sh__  传入一个绝对路径你将获得目录下面的所有类型的数量以及大小。\n\n\n**awk 常用使用方式：**\n\n1. 打印某一列：`awk '{print $1}' filename`。这会打印文件 `filename` 的第一列。\n\n2. 打印多列：`awk '{print $1,$3}' filename`。这会打印文件 `filename` 的第一列和第三列。\n\n3. 条件打印：`awk '$1==\"keyword\" {print $0}' filename`。如果第一列等于 \"keyword\"，则打印整行。\n\n4. 计算总和：`awk '{sum+=$1} END {print sum}' filename`。这会计算文件 `filename` 的第一列的总和。\n\n**sed 常用使用方式：**\n\n1. 替换文本：`sed 's/foo/bar/g' filename`。这会将文件 `filename` 中的 \"foo\" 替换为 \"bar\"。\n\n2. 删除行：`sed '/pattern/d' filename`。这会删除文件 `filename` 中匹配 \"pattern\" 的所有行。\n\n3. 插入文本：`sed '1 i\\Text' filename`。这会在文件 `filename` 的第一行前插入 \"Text\"。\n\n4. 修改行：`sed '3 c\\New text' filename`。这会将文件 `filename` 的第三行替换为 \"New text\"。\n\n**Linux 运维日常使用的脚本列表：**\n\n1. **监控脚本**：这些脚本可以定期检查系统的 CPU 使用率、内存使用率、磁盘空间、网络流量等，并在超出阈值时发送警报。\n\n2. **备份脚本**：这些脚本可以将重要的文件或数据库定期备份到另一台服务器或云存储服务。\n\n3. **日志处理脚本**：这些脚本可以定期压缩、备份、删除旧的日志文件，以防止磁盘空间耗尽。\n\n**日志处理和备份示例脚本：**\n\n```bash\n#!/bin/bash\n\n# 设置日志文件路径\nLOG_PATH=\"/var/log\"\n\n# 设置备份目录\nBACKUP_PATH=\"/backups\"\n\n# 压缩并备份旧的日志文件\nfind $LOG_PATH -name \"*.log\" -mtime +30 | while read LOG_FILE; do\n    echo \"Archiving $LOG_FILE\"\n    tar czf \"$BACKUP_PATH/$(basename $LOG_FILE).tar.gz\" \"$LOG_FILE\"\n    rm \"$LOG_FILE\"\ndone\n```\n\n这个脚本会找到 `/var/log` 目录下所有30天以上的 `.log` 文件，然后将这些文件压缩并备份到 `/backups` 目录，并删除这些旧的日志文件。你可以根据你的实际情况修改这个脚本。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuk0%2Fshe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuk0%2Fshe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuk0%2Fshe/lists"}