大于行首的符号 [英] greater than symbol at beginning of line

查看:92
本文介绍了大于行首的符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在脚本中看到了以下内容,但不确定是什么意思

I've just seen the following in a script and I'm not sure what it means:

.............
started=$STATUSDIR/.$EVENT_ID-started
   errs=$STATUSDIR/.$EVENT_ID-errors

# started is used to capture the time we started, so
# that it can be used as the latest-result marker for
# the next run...
>"$started"
>"$errs"

# store STDERR on FD 3, then point STDERR to $errs
exec 3>&2 2>"$errs"
..............

具体来说,在行的开头是>".该脚本实际上失败,并显示没有此类文件或目录". var都是通过辅助脚本提供的,似乎没有任何逻辑可以创建其抱怨的目录.

Specifically, the ">" at the beginning of the lines. The script actually fails with "No such file or directory". The vars are all supplied via subsidiary scripts and there doesn't seem to be any logic to create the directories it's complaining about.

对于Google而言,这不是最简单的事情,所以我想在这里提出这个问题,以便将来的bash黑客可以找到您可爱的人能够提供的答案.

It's not the easiest thing to Google for, so I thought I'd ask it here so that future bash hackers might find the answers you lovely people are able to provide.

推荐答案

这是重定向.它与echo hello >file(或不太传统但同样正确的等效>file echo hello)所使用的语法相同,只是没有echo hello. :)

This is a redirection. It's the same syntax used for echo hello >file (or its less-conventional but equally-correct equivalent >file echo hello), just without the echo hello. :)

当附加到空命令时,重定向的效果与运行并立即退出而没有任何输出的命令的效果相同:它创建(如果不存在)或截断(如果存在)输出文件,关闭该文件,并让脚本继续执行下一个命令.

When attached to an empty command, the effect of a redirection is identical to what it would be with a command that ran and immediately exited with no output: It creates (if nonexistent) or truncates (if existent) the output file, closes that file, and lets the script move on to the next command.

这篇关于大于行首的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆