用echo把一個(gè)變量或者內(nèi)容轉(zhuǎn)出到文件時(shí)摊滔,
當(dāng)要echo的數(shù)據(jù)太大,太長時(shí),就有可能報(bào)這個(gè)錯(cuò)/bin/echo: Argument list too long
對于這種情況我們可以換另外一種方式:
#!/bin/bash
/bin/cat >filename.txt <<EOT
Your output-text starts here
EOT
這是一種Here Document的寫法,可以用于文本塊的處理冒嫡,## Here Document 是在Linux Shell 中的一種特殊的重定向方式,它的基本的形式如下
cmd << delimiter
Here Document Content
delimiter
它的作用就是將兩個(gè) delimiter 之間的內(nèi)容(Here Document Content 部分) 傳遞給cmd 作為輸入?yún)?shù)四苇。并且兩個(gè) delimiter 之間的內(nèi)容可以用變量孝凌。