⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 generate-script.sh

📁 一本完整的描述Unix Shell 编程的工具书的所有范例
💻 SH
字号:
#!/bin/bash# generate-script.sh# Based on an idea by Albert Reiner.OUTFILE=generated.sh         # Name of the file to generate.# -----------------------------------------------------------# 'Here document containing the body of the generated script.(cat <<'EOF'#!/bin/bashecho "This is a generated shell script."#  Note that since we are inside a subshell,#+ we can't access variables in the "outside" script.echo "Generated file will be named: $OUTFILE"#  Above line will not work as normally expected#+ because parameter expansion has been disabled.#  Instead, the result is literal output.a=7b=3let "c = $a * $b"echo "c = $c"exit 0EOF) > $OUTFILE# -----------------------------------------------------------#  Quoting the 'limit string' prevents variable expansion#+ within the body of the above 'here document.'#  This permits outputting literal strings in the output file.if [ -f "$OUTFILE" ]then  chmod 755 $OUTFILE  # Make the generated file executable.else  echo "Problem in creating file: \"$OUTFILE\""fi#  This method can also be used for generating#+ C programs, Perl programs, Python programs, Makefiles,#+ and the like.exit 0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -