I cannot figure this out... I would like to change the owner of a bunch of folders whose name begins with a dash... # chown Administrator \-BILLED\ JOBS\ -\ 1997-2002 -R chown: invalid option -- B Try `chown --help' for more information. # chown Administrator "\-BILLED\ JOBS\ -\ 1997-2002" -R chown: cannot access `\\-BILLED\\ JOBS\\ -\\ 1997-2002': No such file or directory # chown Administrator "-BILLED JOBS - 1997-2002" -R chown: invalid option -- B Try `chown --help' for more information. # chown Administrator '-BILLED JOBS - 1997-2002' -R chown: invalid option -- B Try `chown --help' for more information. ? Craig
Hi Craig, Craig White wrote:> I cannot figure this out... > > I would like to change the owner of a bunch of folders whose name begins > with a dash...When you are using shell commands, if you use double-dash, you don't need to escape it. [root at red ~]# mkdir -- "-test" [root at red ~]# chown oracle -- -test [root at red ~]# ls -ld -- -test drwxr-xr-x 2 oracle root 4096 Oct 20 16:01 -test -- stops the commands continuing the parsing the parameters as options. Cheers, Hakan
On Mon, Oct 20, 2008 at 11:04 AM, Craig White <craigwhite at azapple.com> wrote:> I cannot figure this out... > > I would like to change the owner of a bunch of folders whose name begins > with a dash... > > # chown Administrator \-BILLED\ JOBS\ -\ 1997-2002 -R > chown: invalid option -- B > Try `chown --help' for more information. > > # chown Administrator "\-BILLED\ JOBS\ -\ 1997-2002" -R > chown: cannot access `\\-BILLED\\ JOBS\\ -\\ 1997-2002': No such file or > directory > > # chown Administrator "-BILLED JOBS - 1997-2002" -R > chown: invalid option -- B > Try `chown --help' for more information. > > # chown Administrator '-BILLED JOBS - 1997-2002' -R > chown: invalid option -- B > Try `chown --help' for more information. > > ?maybe ... # chown -R -- Administrator '-BILLED JOBS - 1997-2002' Make sure all options are before the --, which forces end of options, IIANM. -Bob
On Mon, 2008-10-20 at 08:04 -0700, Craig White wrote:> I cannot figure this out... > > I would like to change the owner of a bunch of folders whose name begins > with a dash... > > # chown Administrator \-BILLED\ JOBS\ -\ 1997-2002 -R > chown: invalid option -- B > Try `chown --help' for more information. > > # chown Administrator "\-BILLED\ JOBS\ -\ 1997-2002" -R > chown: cannot access `\\-BILLED\\ JOBS\\ -\\ 1997-2002': No such file or > directory > > # chown Administrator "-BILLED JOBS - 1997-2002" -R > chown: invalid option -- B > Try `chown --help' for more information. > > # chown Administrator '-BILLED JOBS - 1997-2002' -R > chown: invalid option -- B > Try `chown --help' for more information.In most cases, putting a single '-' signals the last "flag" and says anything thereafter is a "normal" argument. Give it a try like this. I'm not sure though. chown Administrator - "-BILLED JOBS - 1997-2002" -R I'm unsure of the "-R". If a "flag, move it ahead of the '-'.> > ? > > Craig > <snip sig stuff>HTH -- Bill
The right answer is using -- to stop handling command line arguments. There is another trick that might help to do it too: using "./" in front of the filename the filename. # chown Administrator './-BILLED JOBS - 1997-2002' -R This should work. HTH, Filipe