FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 10-20-2008, 03:04 PM
Craig White
 
Default command line escaping a dash

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

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-20-2008, 03:09 PM
Hakan Koseoglu
 
Default command line escaping a dash

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@red ~]# mkdir -- "-test"
[root@red ~]# chown oracle -- -test
[root@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
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-20-2008, 03:15 PM
"Bob Beers"
 
Default command line escaping a dash

On Mon, Oct 20, 2008 at 11:04 AM, Craig White <craigwhite@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
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-20-2008, 03:18 PM
Craig White
 
Default command line escaping a dash

On Mon, 2008-10-20 at 16:09 +0100, Hakan Koseoglu wrote:
> 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@red ~]# mkdir -- "-test"
> [root@red ~]# chown oracle -- -test
> [root@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.
----
I may have known that somewhere in the recesses of my mind

Thanks - solved

Craig

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-20-2008, 03:22 PM
"William L. Maltby"
 
Default command line escaping a dash

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

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-20-2008, 03:24 PM
"William L. Maltby"
 
Default command line escaping a dash

On Mon, 2008-10-20 at 11:22 -0400, William L. Maltby wrote:
> <snip>

> In most cases, putting a single '-' signals the last "flag" and says

Rats! As Hakan said, '--'

> <snip>

--
Bill

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-20-2008, 04:39 PM
"Filipe Brandenburger"
 
Default command line escaping a dash

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
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 

Thread Tools




All times are GMT. The time now is 02:00 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org