Why the file name will be displayed with single quote in RHEL8?
Environment
- RHEL8 and later.
- coreutils-8.25 and later.
Issue
- The file name which contains special character (such as a(b)or space blank) is always displayed as 'a(b)' or 'a b' via 'ls' command since RHEL8.
Resolution
If the user want to keep the older display via 'ls' command, can use the below solutions(choose one):
- Using the
ls -N
option.
[root@node-0 testdir]# ls
'a(b)'
[root@node-0 testdir]# ls -N
a(b)
From man ls
:
-N, --literal
print entry names without quoting
- Using the
export QUOTING_STYLE=literal
as the user's environment parameter.
[root@node-0 testdir]# ls
'a(b)'
[root@node-0 testdir]# export QUOTING_STYLE=literal
[root@node-0 testdir]# ls
a(b)
Root Cause
This is a new behavior since coreutils-8.25, is designed to make the copying file name safe.
ls now quotes file names unambiguously and appropriate for use in a shell,
when outputting to a terminal.
For more details, please refer to the gnu link.
Diagnostic Steps
-
In an os(such as RHEL7) which owns the lower coreutils(<8.25).
Create a file with the below command.
touch a\(b\)
ls
# You will see the output in the terminal(without the quotes).
[root@node-0 test]# rpm -qa|grep coreutils-8
coreutils-8.22-24.el7.x86_64
[root@node-0 test]# touch a\(b\)
[root@node-0 test]# ls
a(b)
-
In an os(such as RHEL8) which owns the higher coreutils(>=8.25).
Create a file with the below command.
touch a\(b\)
ls
# You will see the output in the terminal(with the quotes).
[root@node-0 test]# rpm -qa|grep coreutils-8
coreutils-8.30-12.el8.x86_64
[root@node-0 test]# touch a\(b\)
[root@node-0 test]# ls
'a(b)'
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments