echo "test" > file.txt # bash: file.txt: cannot overwrite existing file
Shell 環境啟用了 noclobber 選項 (set -o noclobber),防止 > 覆蓋既有檔案。
set +o noclobber
echo "test" >| file.txt # 加上 | 符號強制覆蓋
# 註解或移除 # set -o noclobber
set -o | grep noclobber # noclobber on 表示啟用 # noclobber off 表示關閉