Bug 70548 - 'chown -R' with wildcards is not recursive
'chown -R' with wildcards is not recursive
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: fileutils (Show other bugs)
7.3
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: wdovlrrw
Mike McLean
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-08-02 09:20 EDT by Need Real Name
Modified: 2007-04-18 12:45 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-08-02 09:20:45 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2002-08-02 09:20:41 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)

Description of problem:
When I try to change the owner of all HTML-files (*.html) recursively with 
the 'chown' command, it fails to recurse through the directory structure. The 
following example illustrates this:

===========================
[root@developer test]# ls -lR
.:
total 4
-rw-r--r--    1 ahlen    ahlen           0 Aug  2 14:35 file1.html
drwxr-xr-x    2 ahlen    ahlen        4096 Aug  2 14:44 folder
-rw-r--r--    1 ahlen    ahlen           0 Aug  2 15:13 foo.bar

./folder:
total 0
-rw-r--r--    1 ahlen    ahlen           0 Aug  2 14:35 file2.html
[root@developer test]# chown -R root:root *.html
[root@developer test]# ls -lR
.:
total 4
-rw-r--r--    1 root     root            0 Aug  2 14:35 file1.html
drwxr-xr-x    2 ahlen    ahlen        4096 Aug  2 14:44 folder
-rw-r--r--    1 ahlen    ahlen           0 Aug  2 15:13 foo.bar

./folder:
total 0
-rw-r--r--    1 ahlen    ahlen           0 Aug  2 14:35 file2.html
===========================

If I use only '*' as a wildcard the recursion works but the intended purpose 
is defeated since this changes all files and not only .html files.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
See example above

Actual Results:  The .html file inside 'folder' didn't change owner.

Expected Results:  The .html file inside 'folder' should be owned by root.

Additional info:
Comment 1 Mike McLean 2002-08-02 11:35:03 EDT
CLOSED->NOTABUG

This is just the way that recursive file utilities work.  You give them a list
of files and they act on those files.  If some of those files are directories
and you have asked for recursion, then the utility will also act on *all files*
in those directories and so on, all the way down the tree.

The key thing here is that the utility does not recieve the argument "*.html". 
The *shell* expands this to a list of files before running the utility.

The command you want would be something like:

% find . -name "*.html" -exec chown root:root '{}' ';'

Or even:

% find . -name "*.html" |xargs chown root:root
Comment 2 Mike McLean 2002-08-02 11:40:43 EDT
Note how "*.html" is in quotes in the find commands. This protects it from shell
expansion, so that find sees the pattern itself.  

OTOH, if you tried this with most other utilities, you'd probably get an error
because they only understand filenames.
$ chown -R root:root "*.html"
chown: getting attributes of `*.html': No such file or directory
Comment 3 Need Real Name 2002-08-02 11:45:11 EDT
Thanks!

I guess the bug was in my knowledge instead of in the binary. Keep up the good 
work!

Note You need to log in before you can comment on or make changes to this bug.