linux - sed命令更改文件权限linux

标签 linux shell unix

我正在尝试在脚本中使用此命令替换文件中的字符串:-

sed -i "find replace" file_name

但此后文件权限正在更改。

请帮忙

最佳答案

我的 Fedora 系统上保留了权限。在任何情况下,您都可以告诉 sed 保留旧文件。然后你可以复制权限:

sed -i.old "find replace" file_name
chmod --reference file_name.old file_name
rm file_name.old

关于linux - sed命令更改文件权限linux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37163619/

相关文章:

linux - 如何在没有 root 权限的情况下安装 Bioconductor 软件包?

linux - Unix : replace variable in file a with value in file b

linux - 文件中包含整数的行数

json - 其他命令中的管道命令输出

php - 如何在 shell_exec 函数中包含 shell 命令?

bash - 如何在 Unix 中同时写入文件和打印到终端?

linux - awk 比较两个文件的列,如果在文件 1 中没有看到,则打印文件 2 的列

c++ - 在linux下编译leveldb c++程序出错?

linux - 具有进程替换的 shell 脚本中的语法错误

Linux bash 脚本 -