bash
1
总安装量
1
周安装量
#77909
全站排名
安装命令
npx skills add https://github.com/g1joshi/agent-skills --skill bash
Agent 安装分布
mcpjam
1
claude-code
1
replit
1
junie
1
windsurf
1
zencoder
1
Skill 文档
Bash
Bourne Again SHell, the standard shell for Linux and macOS.
When to Use
- Automating system tasks
- CI/CD pipelines
- File manipulation
- Glue code between CLIs
Quick Start
#!/bin/bash
NAME="World"
echo "Hello, $NAME!"
if [ -f "file.txt" ]; then
echo "File exists"
else
echo "File not found"
fi
Core Concepts
Variables
No data types. Everything is a string.
count=10
echo $count
Pipes and Redirection
|: Pipe output of one command to input of next.>: Redirect output to file (overwrite).>>: Redirect output to file (append).
cat file.txt | grep "error" > errors.log
Exit Codes
Commands return 0 for success and non-zero for failure. Check with $?.
Best Practices
Do:
- Use
set -e(e)xit on error - Use
set -u(u)nset variable usage is error - Use
set -o pipefailto catch errors in pipes - Quote variables
"$VAR"to handle spaces
Don’t:
- Parse
lsoutput (use globs*) - Use simple
[vs[[(double brackets are safer)