Skip to main content Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Un comando directo omite el prompt de revisión. Revisa el origen antes de ejecutarlo.
npx skills add https://github.com/ffsshhttiikk/opencode-agents-skills --skill bashEl comando permanece en una sola línea. Desplázate horizontalmente para revisarlo antes de copiarlo.
¿Prefieres una copia local? Descarga los archivos que SkillsMP tiene disponibles ahora.
Ocupaciones relacionadasSOC
Basado en la clasificación ocupacional SOC
| 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"} |
What I do
- Write automation scripts for system tasks
- Process and transform data files
- Manage processes and system resources
- Create interactive shell menus
- Parse logs and configuration files
- Handle error conditions and debugging
- Manage text processing with grep, sed, awk
- Schedule jobs with cron and at
- Create reusable script functions
- Build complex workflows
When to use me
When automating system administration tasks, processing data files, creating shell scripts, or working in Linux/Unix environments.
Core Concepts
- Bash scripting syntax and best practices
- Parameter expansion and quoting
- Process substitution and pipes
- Control structures (if, case, loops, functions)
- Regular expressions with grep/sed/awk
- Exit codes and error handling
- Arrays and associative arrays
- Here-documents and here-strings
- Signal handling and traps
- Subshells and command grouping
Code Examples
System Automation Scripts
#!/usr/bin/env bash
set -euo pipefail
readonly LOG_FILE="/var/log/backup.log"
readonly BACKUP_DIR="/backup"
readonly RETENTION_DAYS=30
log() {
local level="$1"
shift
local message="$@"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [$level] $message" | tee -a "$LOG_FILE"
}
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
Advanced Data Processing
#!/usr/bin/env bash
set -euo pipefail
generate_user_report() {
local csv_file="$1"
local output_dir="$2"
mkdir -p "$output_dir"
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"
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"
}
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 _ {}
}
Network Utilities
#!/usr/bin/env bash
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
}
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=
}
Best Practices
- Always use
set -euo pipefail at script start
- Use double quotes around variables to prevent word splitting
- Use
readonly for constants and configuration values
- Prefer
printf over echo for portable output
- Use functions to organize code and enable testing
- Return meaningful exit codes (0=success, non-zero=failure)
- Document scripts with comments and usage functions
- Handle signals with trap for cleanup
- Avoid parsing output of
ls - use globs instead
- Test scripts with shellcheck for common issues
cut
log
"INFO"
"Backup completed: $backup_file ($size)"
if
"$backup_file"
then
log
"INFO"
"Backup verified successfully"
else
log
"ERROR"
"Backup verification failed!"
return
fi
else
log
"ERROR"
"Backup failed for database: $db_name"
return
fi
cleanup_old_backups
log
"INFO"
"Cleaning up backups older than $RETENTION_DAYS days"
local
while
read
''
do
rm
"$file"
log
"INFO"
"Removed: $file"
done
"$BACKUP_DIR"
"*.sql.gz"
$RETENTION_DAYS
log
"INFO"
"Cleaned up $deleted old backup files"
health_check
local
local
if
df
'NR==2 {exit ($5 > 90)}'
then
log
"INFO"
"Disk space check: PASSED"
else
log
"ERROR"
"Disk space check: FAILED (>/= 90% used)"
fi
local
'/Mem:/ {printf "%.0f", $3/$2 * 100}'
if
$mem_usage
90
then
log
"INFO"
"Memory check: PASSED ($mem_usage%)"
else
log
"ERROR"
"Memory check: FAILED ($mem_usage%)"
fi
for
in
do
if
"$service"
then
log
"INFO"
"Service $service: RUNNING"
else
log
"ERROR"
"Service $service: NOT RUNNING"
fi
done
log
"INFO"
"Health check complete: $checks_passed passed, $checks_failed failed"
return
$checks_failed
main
log
"INFO"
"========================================="
log
"INFO"
"Backup script started"
log
"WARN"
"Health check failed, but continuing with backup"
for
in
do
"$db"
log
"ERROR"
"Failed to backup: $db"
done
log
"INFO"
"Backup script completed"
log
"INFO"
"========================================="
"$@"
local
"$2"
local
"${3:-4}"
export
"$dest_dir"
process_single_file
local
"$1"
local
basename
basename
"$file"
echo
"Processing $basename to $DEST_DIR"
cp
"$file"
"$DEST_DIR/${basename%.txt}_processed.txt"
export
"$source_dir"
"*.txt"
"$max_jobs"
'process_single_file "$@"'
echo
"------- ------- ------ ------"
local
cat
$interface
local
cat
$interface
while
true
do
sleep
"$interval"
local
cat
$interface
local
cat
$interface
local
local
printf
"%7.2f %7.2f %7.2f %7.2f\n"
1024
1024
1024
1024
echo
"scale=2; $rx_diff / 1024 / 1024 / $interval"
echo
"scale=2; $tx_diff / 1024 / 1024 / $interval"
$curr_rx
$curr_tx
done