【问题标题】:In linux terminal it says file exists在linux终端它说文件存在
【发布时间】:2018-03-16 14:32:19
【问题描述】:

当我运行一个程序并且我想将该程序的输出发送到一个文件中时。 我尝试了什么

> tclsh hello.tcl > temp_out.txt

第一次将输出发送到 temp_out.txt 文件,但如果我再次运行,它会说 文件存在

> tclsh hello.tcl > temp_out.txt
> temp_out.txt : File exists

我希望当我运行这个程序时它应该删除文件的内容并再次将输出添加到 temp_out.txt 文件..

【问题讨论】:

  • 你正在使用哪个外壳
  • echo $SHELL 给出“/bin/tcsh”
  • 关闭noclobber变量。
  • SO 是针对编程问题,而不是关于使用或配置 Linux 的问题。 SuperUser.com 或 unix.stackexchange.com 将是解决此类问题的更好地方。

标签: linux file terminal tcsh


【解决方案1】:

试试这样跑,

tclsh hello.tcl >! temp_out.txt

它将覆盖现有的[temp_out.txt] 文件。

【讨论】:

  • “缺少重定向名称”收到此错误
  • 应该是>! 而不是>|
  • 这是bash 语法,上面的评论说他使用的是tcsh
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-23
  • 2014-10-23
  • 1970-01-01
  • 2023-03-14
  • 2022-11-23
  • 2016-09-23
相关资源
最近更新 更多