【问题标题】:Setting file permissions for created files in R在 R 中为创建的文件设置文件权限
【发布时间】:2017-06-19 15:00:28
【问题描述】:

我在 Linux 上,希望与同事共享 R 输出,同时还允许他们覆盖我的文件。但是,当我编写文件时,该组的权限设置为只读,例如:

> write.csv(data.frame(a = 1:3), file = "/tmp/test.csv")
> file.mode("/tmp/test.csv")
[1] "644"

创建一个只能由我自己写入的文件。是否可以设置一些选项,以便我编写的文件具有自动设置所有写入文件方式的权限660write.csvdata.table 等)?

【问题讨论】:

    标签: r file-permissions


    【解决方案1】:

    解决方法是使用Sys.umask设置umask,如下所示。

    # Before setting umask as in the question:
    > write.csv(data.frame(a = 1:3), file = "/tmp/test.csv")
    > file.mode("/tmp/test.csv")
    [1] "644"
    # Setting the umask results in succes:
    Sys.umask("006")
    > write.csv(data.frame(a = 1:3), file = "/tmp/test2.csv")
    > file.mode("/tmp/test2.csv")
    [1] "660"
    

    【讨论】:

      猜你喜欢
      • 2021-01-17
      • 1970-01-01
      • 2018-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-08
      • 1970-01-01
      相关资源
      最近更新 更多