我有一个脚本来收集指标,然后将该脚本的结果输出到文件中
这是我正在运行的命令
bash get_metrics > metrics.txt
这有效
现在我要在文件上附加日期
通过跑步
bash get_metrics > metrics-$(date +%y/%m/%d).txt
运行此命令后,出现此错误
'zsh:no such file or directory: metrics-2018/12/23.txt'
通过阅读这些帖子(1和2),看来问题出在我使用'/'-斜杠。 Bash必须以为我正在尝试创建一个新目录。当我将斜杠更改为破折号(-)时,此命令有效。如何告诉bash我不是要创建任何新目录,也不要将破折号视为文件名的一部分?
答案 0 :(得分:2)
我猜你应该使用
render() {
// Extract typeOfFocused from state
const { typeOfFocused } = this.state
// Render input type with typeOfFocused if present, or as text by default
return (<input placeholder="Date"
type={ typeOfFocused || 'text' }
onFocus={ () => this.setState({ typeOfFocused : 'date' }) }
onBlur={ () => this.setState({ typeOfFocused : '' }) }
id="date">)
}
避免使用bash get_metrics >> metrics-$(date +%y-%m-%d).txt
(它是目录分隔符)和/
(附加)。