Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
zzcontinent
/
shell
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
2
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
github
Breadcrumbs
shell
/
bash_skill.sh
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
44 lines (37 loc) · 1.19 KB
github
Breadcrumbs
shell
/
bash_skill.sh
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
44 lines (37 loc) · 1.19 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#/bin/bash
#执行前把命令展开并打印
set -x
#遇到命令失败(ret != 0),立即退出
set -e
cmd_xxx || true
set -e cmd1; set +e cmd2; set -e;
#set +e 暂时取消报错 ()
#使用未定义的变量立即退出
set -u
${var:-}
#管道中一个命令出错,立即退出
-o pipefail
#防止重复运行
flock --wait 5 -e 'lock_myscript' -c "bash myscript.sh"
exec 123<>lock_myscript #把lock_myscript打开为文件锁123
flock --wait 5 123 || { echo 'cannot get lock';exit 1; }
#意外退出时,杀掉所有子进程
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
#超时退出
timeout 600s cmd1 arg1 arg2
#1. # 号截取,删除左边字符,保留右边字符
echo ${var#*//}
#2. ## 号截取,删除左边字符,保留右边字符
echo ${var##*/}
#3. %号截取,删除右边字符,保留左边字符
echo ${var%/*}
#4. %号截取,删除右边字符,保留左边字符
echo ${var%%/*}
#5. 从左边第几个字符开始,及字符的个数
echo ${var:0:5}
#6. 从左边第几个字符开始,一直到结束。
echo ${var:7}
#7. 从右边第几个字符开始,及字符的个数
echo ${var:0-7:3}
#8. 从右边第几个字符开始,一直到结束。
echo ${var:0-7}
You can’t perform that action at this time.