基于 SOC 职业分类
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ffsshhttiikk/opencode-agents-skills --skill bash命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | bash |
| description | Bash shell scripting for automation, system administration, and command-line productivity |
| license | MIT |
| compatibility | opencode |
| metadata | {"audience":"system-administrators","category":"systems-administration"} |
When automating system administration tasks, processing data files, creating shell scripts, or working in Linux/Unix environments.
#!/usr/bin/env bash
set -euo pipefail
# Configuration
readonly LOG_FILE="/var/log/backup.log"
readonly BACKUP_DIR="/backup"
readonly RETENTION_DAYS=30
# Logging function
log() {
local level="$1"
shift
local message="$@"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [$level] $message" | tee -a "$LOG_FILE"
}
# Database backup function
backup_postgresql() {
local db_name="$1"
local timestamp=$(date +%Y%m%d_%H%M%S)
local backup_file="${BACKUP_DIR}/${db_name}_${timestamp}.sql.gz"
log "INFO" "Starting backup of database: $db_name"
if pg_dump "$db_name" | gzip > "$backup_file"; then
local size=$(du -h "$backup_file" | -f1)
gzip -t 2>/dev/null;
1
1
}
() {
deleted=0
IFS= -r -d file;
-f
((deleted++))
< <(find -name -mtime + -print0)
}
() {
checks_passed=0
checks_failed=0
/ | awk ;
((checks_passed++))
((checks_failed++))
mem_usage=$(free | awk )
(( $(echo " < " | bc -l) ));
((checks_passed++))
((checks_failed++))
service nginx postgresql redis;
systemctl is-active --quiet ;
((checks_passed++))
((checks_failed++))
}
() {
health_check || {
}
db app_production app_staging;
backup_postgresql ||
cleanup_old_backups
}
main
#!/usr/bin/env bash
set -euo pipefail
# Parse CSV and generate reports
generate_user_report() {
local csv_file="$1"
local output_dir="$2"
# Create output directory
mkdir -p "$output_dir"
# Process CSV with awk
awk -F',' '
NR > 1 {
# Count by department
dept_count[$3]++
# Sum salaries
dept_salary[$3] += $5
# Track active/inactive
if ($6 == "active") active_count++
else inactive_count++
}
END {
print "Department Report"
print "================="
for (dept in dept_count) {
printf "%-20s: %3d employees, $%10.2f avg salary\n", \
dept, dept_count[dept], dept_salary[dept] / dept_count[dept]
}
printf "\nTotal Active: %d\nTotal Inactive: %d\n", active_count, inactive_count
}' "$csv_file" > "$output_dir/department_summary.txt"
# Generate JSON with jq-like approach using Python
python3 <<PYEOF
import csv
import json
import sys
data = []
with open('$csv_file', 'r') as f:
reader = csv.DictReader(f)
for row in reader:
data.append({
'id': int(row['id']),
'name': row['name'],
'email': row['email'],
'department': row['department'],
'salary': float(row['salary'])
})
with open('$output_dir/users.json', 'w') as f:
json.dump(data, f, indent=2)
PYEOF
log "INFO" "Reports generated in $output_dir"
}
# Concurrent processing with GNU parallel
process_files_concurrent() {
local source_dir="$1"
dest_dir=
max_jobs=
DEST_DIR=
() {
file=
=$( )
}
-f process_single_file
find -name -print0 | \
xargs -0 -P -I {} bash -c _ {}
}
#!/usr/bin/env bash
# Port scanner
scan_ports() {
local host="${1:-localhost}"
local start_port="${2:-1}"
local end_port="${3:-1024}"
echo "Scanning $host ports $start_port-$end_port..."
for port in $(seq $start_port $end_port); do
if timeout 0.5 bash -c "echo > /dev/tcp/$host/$port" 2>/dev/null; then
echo "Port $port: OPEN ($(grep "^$port/" /etc/services 2>/dev/null | cut -f1 || echo 'unknown')"
fi
done
}
# Network bandwidth monitor
monitor_bandwidth() {
local interface="${1:-eth0}"
local interval="${2:-1}"
echo "Monitoring $interface bandwidth (interval: ${interval}s)"
echo "RX (MB) TX (MB) RX/s TX/s"
prev_rx=$( /sys/class/net//statistics/rx_bytes)
prev_tx=$( /sys/class/net//statistics/tx_bytes)
;
curr_rx=$( /sys/class/net//statistics/rx_bytes)
curr_tx=$( /sys/class/net//statistics/tx_bytes)
rx_diff=$((curr_rx - prev_rx))
tx_diff=$((curr_tx - prev_tx))
\
$((curr_rx / / )) $((curr_tx / / )) \
$( | bc) \
$( | bc)
prev_rx=
prev_tx=
}
set -euo pipefail at script startreadonly for constants and configuration valuesprintf over echo for portable outputls - use globs instead