今天學到一個Linux Bash的新詞語,Here docuemnts。
Frequently, your script might call on another program or script that requires input. The here document provides a way of instructing the shell to read input from the current source until a line containing only the search string is found (no trailing blanks). All of the lines read up to that point are then used as the standard input for a command.
簡答的說,就是直接將需要的文件內容寫到Bash一起。echo "These are the web browsers on this system:" # Start here document cat << BROWSERS mozilla links lynx konqueror opera netscape BROWSERS # End here document
從上面可以看出,以BROWSERS開始,到BROWSERS結束為一個文檔。