Perl in-place edit fails with "File exists" error, and deletes the original file from CIFS share on RHEL systems.
Issue
-
When performing in-place edits using
perlon files stored on a CIFS share, it results in a failure, and the original file is deleted and not re-created, leading to data loss:# echo test1 > /path/to/cifs/share/a.txt # cat /path/to/cifs/share/a.txt test1 # perl -pe 's/test1/test2/g' -i /path/to/cifs/share/a.txt Can't do inplace edit on a.txt: File exists. # ls -l /path/to/cifs/share total 0 # perl -pe 's/test1/test2/g' -i /path/to/cifs/share/a.txt Can't open a.txt: No such file or directory. -
This issue doesn't occur on local filesystems or with NFS.
-
Why does this issue only occur on CIFS-mounted shares and not on local filesystems?
-
Perl in-place edit (perl -i -pe ...) fails with Can't do in-place edit on
: No such file or directory. -
Is this a known issue with Perl in RHEL or with CIFS/Azure File Shares?
Environment
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 8
- Red Hat Enterprise Linux 9
- Perl version: 5.26.3, 5.16.3, 5.32.1
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.