📄 script-array.sh
字号:
#!/bin/bash# script-array.sh: Loads this script into an array.# Inspired by an e-mail from Chris Martin (thanks!).script_contents=( $(cat "$0") ) # Stores contents of this script ($0) #+ in an array.for element in $(seq 0 $((${#script_contents[@]} - 1))) do # ${#script_contents[@]} #+ gives number of elements in the array. # # Question: # Why is seq 0 necessary? # Try changing it to seq 1. echo -n "${script_contents[$element]}" # List each field of this script on a single line. echo -n " -- " # Use " -- " as a field separator.doneechoexit 0# Exercise:# --------# Modify this script so it lists itself#+ in its original format,#+ complete with whitespace, line breaks, etc.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -