【问题标题】:Redirect to file directory non existent重定向到不存在的文件目录
【发布时间】:2015-02-20 04:17:14
【问题描述】:

我在 Python 中调用这个命令:

os.system('echo %s  > `find $HOME -iname p410.yaml`' % string)

这在 OSX 上运行良好,但在 Ubuntu 上给我/home/path/to/p410.yaml: Directory nonexistent。但是,我可以使用 vim 在它给我的路径上编辑文件。

知道怎么了?

编辑

stat find $HOME -iname p410.yaml的输出

File: `/home/aslab/chris_ws/src/pulseon_p400/config/p410.yaml'
  Size: 124         Blocks: 8          IO Block: 4096   regular file
Device: 805h/2053d  Inode: 460669      Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1001/   aslab)   Gid: ( 1001/   aslab)
Access: 2014-12-22 13:45:57.000000000 +1000
Modify: 2014-12-22 13:44:45.000000000 +1000
Change: 2014-12-22 13:44:45.000000000 +1000
 Birth: -
  File: `/home/aslab/uwb_ws/src/pulseon_p400/launch/p410.yaml'
  Size: 163         Blocks: 8          IO Block: 4096   regular file
Device: 805h/2053d  Inode: 457183      Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1001/   aslab)   Gid: ( 1001/   aslab)
Access: 2014-12-19 08:11:30.000000000 +1000
Modify: 2014-09-12 14:37:19.000000000 +1000
Change: 2014-09-12 14:37:19.000000000 +1000
 Birth: -

【问题讨论】:

  • 你为什么使用sudo
  • 这只是试图让它工作,它真的无关紧要。生病删除它以避免混淆
  • 如果直接在shell中运行find $HOME -iname p410.yaml会发生什么?
  • 它返回给我它的路径。它让我去 vim find ... p410.yam 很好
  • 如果你运行stat `find $HOME -iname p410.yaml`会怎样?

标签: python bash ubuntu


【解决方案1】:

这里的问题是有两个同名文件,通过 Python 解释器过滤的错误消息有点模糊。老实说,我也很惊讶当我打电话给vim 'find $HOME -iname p410.yaml' 时,当有两个选项可以打开哪个文件时它起作用了。

【讨论】:

  • 毫不奇怪,vim onefile another 只会一次编辑两个文件(当您完成第一个文件时,:n 会将您转到第二个文件)。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-04
  • 1970-01-01
  • 2014-09-28
相关资源
最近更新 更多