單行文本
#! /bin/bash echo Hello > filename.txt
多行文本
#! /bin/bash
echo "測試寫檔案"
cat>test1<<EOF
這是一個由shell建立的檔案
this is a file created by shell.
we want to make a good world.
EOF
其中,<<EOF 表示當遇到EOF時結束輸入。
cat>test1<<EOF 這間沒有空格
#! /bin/bash echo Hello > filename.txt
#! /bin/bash
echo "測試寫檔案"
cat>test1<<EOF
這是一個由shell建立的檔案
this is a file created by shell.
we want to make a good world.
EOF
其中,<<EOF 表示當遇到EOF時結束輸入。
cat>test1<<EOF 這間沒有空格