Guest User

Untitled

a guest
Sep 25th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.42 KB | None | 0 0
  1. #!/bin/bash
  2. topdir=/var/test
  3.  
  4. ## enter into the directory so we can get a non-pathed listing of directory names
  5. cd $topdir
  6. ## Enable nullglob so it expands wildcard only if file exists, and doesn't expand to a literal "*"
  7.  
  8. shopt -s nullglob # enable
  9. for file in ( * )
  10.     do
  11.     ## param substitute to strip the prefix off the file/dirname, and assign it as owner variable
  12.     owner=${file//\.*/}
  13.     chown -vR $owner $file
  14. done
Add Comment
Please, Sign In to add comment