2

I want to use Fabric to chown all the files in a directory - including hidden files. Since Fabric uses the sh shell and not bash and sh doesn't know shopt, I can't do:

local('shopt -s dotglob')
local('sudo chown -R name dir')

I don't think there is a way to use the bash shell in Fabric. Is there another way to do this?

1 Answer 1

1

How about using another strategy to recursively chown everything in the directory, including hidden files and directories:

local('sudo find dir -exec chown name {} \;')

Hope that helps.

4
  • That looks good, thanks. Could you explain what the "{} \;" does?
    – Mitch
    Jul 10, 2013 at 20:59
  • You are welcome. It works like xargs - needed for passing the next result of find to the chown. In other words {} will be replaced with the next file/dir name. \; is greatly explained here.
    – alecxe
    Jul 10, 2013 at 21:04
  • 1
    Another alternative from [stackoverflow.com/questions/8005348/…: local("/bin/bash -l -c 'shopt -s dotglob'")
    – Mitch
    Jul 11, 2013 at 3:03
  • Also in more recent versions of Fabric (1.6 at least and I am using 1.3), the local function accepts shell as a keyword parameter.
    – Mitch
    Jul 11, 2013 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.