?? generate-script.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 + -