prepend.sh
来自「BASH Shell 编程 经典教程 《高级SHELL脚本编程》中文版」· Shell 代码 · 共 31 行
SH
31 行
#!/bin/bash# prepend.sh: 在文件的开头添加文本. ## Kenny Stauffer所捐助的脚本例子, #+ 本文作者对这个脚本进行了少量修改. E_NOSUCHFILE=65read -p "File: " file # 'read'命令的-p参数用来显示提示符. if [ ! -e "$file" ]then # 如果这个文件不存在, 那就进来. echo "File $file not found." exit $E_NOSUCHFILEfiread -p "Title: " titlecat - $file <<<$title > $file.newecho "Modified file is $file.new"exit 0# 下边是'man bash'中的一段: # Here String# here document的一种变形,形式如下: # # <<<word# # word被扩展并且被提供到command的标准输入中.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?