prepend.sh

来自「Shall高级编程」· Shell 代码 · 共 31 行

SH
31
字号
#!/bin/bash# prepend.sh: Add text at beginning of file.##  Example contributed by Kenny Stauffer,#+ and slightly modified by document author.E_NOSUCHFILE=65read -p "File: " file   # -p arg to 'read' displays prompt.if [ ! -e "$file" ]then   # Bail out if no such file.  echo "File $file not found."  exit $E_NOSUCHFILEfiread -p "Title: " titlecat - $file <<<$title > $file.newecho "Modified file is $file.new"exit 0# from 'man bash':# Here Strings# 	A variant of here documents, the format is:# # 		<<<word# # 	The word is expanded and supplied to the command on its standard input.

⌨️ 快捷键说明

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