Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- topdir=/var/test
- ## enter into the directory so we can get a non-pathed listing of directory names
- cd $topdir
- ## Enable nullglob so it expands wildcard only if file exists, and doesn't expand to a literal "*"
- shopt -s nullglob # enable
- for file in ( * )
- do
- ## param substitute to strip the prefix off the file/dirname, and assign it as owner variable
- owner=${file//\.*/}
- chown -vR $owner $file
- done
Add Comment
Please, Sign In to add comment