sh [SHELL / BASH脚本]
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh [SHELL / BASH脚本]相关的知识,希望对你有一定的参考价值。
# My snipets for shell scripting #shell #sh #bash #unix #terminal
# Autostart script in debian linux
https://debian-administration.org/article/28/Making_scripts_run_at_boot_time_with_Debian
# Simple interrupt
read -p "Press any key to continue " -n 1
# Interrupt with timeout
read -p "Press any key to continue (autocontinue in 30 seconds) " -t 30 -n 1
# Rename multiple files (.txt to .lst)
for file in *.txt; do mv ${file%.txt}{.txt,.lst}; done
# Sequenz simple
for srv in server{1..3}; do echo $srv;done
server1
server2
server3
# Sequenze with format
for srv in `seq -w 1 4`; do echo server${srv};done
server01
server02
server03
server04
# Working with strings
$ STRING="username:homedir:shell"
$ echo "$STRING"|cut -d ":" -f 3
shell
$ echo "${STRING##*:}"
shell
# Check env
command -v docker > /dev/null 2>&1 || { echo "[ERROR] Please install docker first"; exit 1; }
command -v jq > /dev/null 2>&1 || { echo "[ERROR] Please install jq first"; exit 1; }
command -v socat > /dev/null 2>&1 || { echo "[ERROR] Please install socat first"; exit 1; }
command -v curl > /dev/null 2>&1 || { echo "[ERROR] Please install curl first"; exit 1; }
# Check system options
if [ -x $(command -v systemctl) ]; then
INIT_SYSTEM=systemd
else
INIT_SYSTEM=sysvinit
echo "[ERROR] Only systemd is supprted at the moment"
exit 1
fi
以上是关于sh [SHELL / BASH脚本]的主要内容,如果未能解决你的问题,请参考以下文章
shell sh bash 概念
如何在不使用“sh”或“bash”命令的情况下运行 shell 脚本?
shell脚本结构和执行方法
sh [SHELL / BASH脚本]
sh 自解压shell bash脚本
linuxshell 脚本执行的过程是怎样的?