Где-нибудь я встретился с командой Terminal, которая имеет следующий формат:
command-name > &! file-name
Что, как предполагается, делает?
Единственная раковина, о которой я знаю, в котором > &!
действительно, (t)csh
. От man tcsh
:
> name >! name >& name >&! name The file name is used as standard output. If the file does not exist then it is created; if the file exists, it is trun‐ cated, its previous contents being lost. If the shell variable noclobber is set, then the file must not exist or be a character special file (e.g., a terminal or `/dev/null') or an error results. This helps prevent acciden‐ tal destruction of files. In this case the `!' forms can be used to suppress this check. If notempty is given in noclob‐ ber, `>' is allowed on empty files; if ask is set, an interacive confirmation is presented, rather than an error. The forms involving `&' route the diagnostic output into the specified file as well as the standard output. name is expanded in the same way as `<' input filenames are.
Напр. если file
существует, но nofile
не делает, то
$ csh -c 'set noclobber; ls -l file nofile > & outfile'
$ cat outfile
ls: cannot access 'nofile': No such file or directory
-rw-r--r-- 1 steeldriver steeldriver 70 Nov 22 15:10 file
Тогда
$ csh -c 'set noclobber; ls -l file nofile > & outfile'
outfile: File exists.
, Но добавление !
$ csh -c 'set noclobber; ls -l file nofile > &! outfile'
имеет успех. Так эти !
имеет несколько подобное значение к этому в vi
.