symlink files are redirected to zero bytes when ls -l | su

Solution Verified - Updated -

Issue

  • I want to know why the file size is changed to "0" through the command. and only certain files change to "0"?

  • Is there any way to avoid this problem?

$ cd /usr/bin
$ ls -al | bash
bash: line 1: total: command not found
bash: line 2: dr-xr-xr-x.: command not found
bash: line 3: drwxr-xr-x.: command not found
bash: line 4: -rwxr-xr-x: command not found
...


$ find /usr/bin/ -size 0 -exec ls -al {} \;|awk '{print $9}'

# Before executing the command (no target file). )

# After executing the command (there is a file whose size has been changed to "0". )

...
-rwxr-xr-x   1 root root         0 Dec 29 15:16 bashbug-64
-rw-r--r--   1 root root         0 Dec 29 15:16 bzdiff
-rw-r--r--   1 root root         0 Dec 29 15:16 bzip2
-rw-r--r--   1 root root         0 Dec 29 15:16 bzmore
-rwxr-xr-x   1 root root         0 Dec 29 15:16 consolehelper
...

Environment

  • Red Hat Enterprise Linux

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content