Yanor.net/
Wiki
Blog
GitHub
Sandbox
開始行:
* noclobberでリダイレクトによる上書きを禁止 [#cff7c7a9]
** 設定を確認 [#j306f99e]
$ set -o | grep noclobber
noclobber off
** noclobberをオンにしてリダイレクトによる上書きを禁止す...
$ set -o noclobber
$ touch 1.txt
$ date > 1.txt
-bash: 1.txt: cannot overwrite existing file
上書きしようとするとエラーが発生する。
** noclobberをオフにしてリダイレクトによる上書きを禁止を...
$ set +o noclobber
$ date > 1.txt
上書きOK。
** パイプを使ってnoclobbberによる上書き禁止を回避する [#t...
$ set -o noclobber
$ touch 1.txt
$ date > 1.txt
-bash: 1.txt: cannot overwrite existing file
$ date >| 1.txt
「>|」を指定する事で上書き禁止を回避出来る。
終了行:
* noclobberでリダイレクトによる上書きを禁止 [#cff7c7a9]
** 設定を確認 [#j306f99e]
$ set -o | grep noclobber
noclobber off
** noclobberをオンにしてリダイレクトによる上書きを禁止す...
$ set -o noclobber
$ touch 1.txt
$ date > 1.txt
-bash: 1.txt: cannot overwrite existing file
上書きしようとするとエラーが発生する。
** noclobberをオフにしてリダイレクトによる上書きを禁止を...
$ set +o noclobber
$ date > 1.txt
上書きOK。
** パイプを使ってnoclobbberによる上書き禁止を回避する [#t...
$ set -o noclobber
$ touch 1.txt
$ date > 1.txt
-bash: 1.txt: cannot overwrite existing file
$ date >| 1.txt
「>|」を指定する事で上書き禁止を回避出来る。
ページ名: