Re: [PLUG] Reading a file with a dash
On Tue, 29 Jun 2021, Michael Barnes wrote: Somehow, I managed to create a file named -u. I cannot figure out how to look at it as any command I give thinks -u is an option, not the filename. I cannot read, edit, move, delete, or anything. Ideas appreciated. Most GNU utilities will stop interpreting options when they encounter a bare ' -- ' string. So this should work mv -- -u newfilename Or, just use the . directory in the filename: less ./-u -- Paul Heinlein heinl...@madboa.com 45.38° N, 122.59° W
Re: [PLUG] Reading a file with a dash
On Tue, 29 Jun 2021, Paul Heinlein wrote: Most GNU utilities will stop interpreting options when they encounter a bare ' -- ' string. So this should work mv -- -u newfilename Or, just use the . directory in the filename: less ./-u Perhaps "-u" will work, too. Rich
Re: [PLUG] Reading a file with a dash
On Tue, Jun 29, 2021 at 7:47 AM Paul Heinlein wrote: > On Tue, 29 Jun 2021, Michael Barnes wrote: > > > Somehow, I managed to create a file named -u. I cannot figure out how to > > look at it as any command I give thinks -u is an option, not the > filename. > > > > I cannot read, edit, move, delete, or anything. > > > > Ideas appreciated. > > Most GNU utilities will stop interpreting options when they encounter > a bare ' -- ' string. So this should work > > mv -- -u newfilename > > Or, just use the . directory in the filename: > > less ./-u > > -- > Paul Heinlein > heinl...@madboa.com > 45.38° N, 122.59° W Paul got it, although I figured it out about ten minutes after I sent my request. less ./-u did the trick. Thanks, Michael
Re: [PLUG] Reading a file with a dash
On Tue, Jun 29, 2021 at 9:06 PM Michael Barnes wrote: > On Tue, Jun 29, 2021 at 7:47 AM Paul Heinlein wrote: > > > On Tue, 29 Jun 2021, Michael Barnes wrote: > > > > > Somehow, I managed to create a file named -u. I cannot figure out how > to > > > look at it as any command I give thinks -u is an option, not the > > filename. > > > > > > I cannot read, edit, move, delete, or anything. > > > > > > Ideas appreciated. > > > > Most GNU utilities will stop interpreting options when they encounter > > a bare ' -- ' string. So this should work > > > > mv -- -u newfilename > > > > Or, just use the . directory in the filename: > > > > less ./-u > > > > -- > > Paul Heinlein > > heinl...@madboa.com > > 45.38° N, 122.59° W > > > Paul got it, although I figured it out about ten minutes after I sent my > request. > less ./-u did the trick. > > Thanks, > Michael > This actually comes up so often that there's a section in the man page about it: $ man rm | cat -n | grep -B1 -A5 starts 56 57 To remove a file whose name starts with a '-', for example '-foo', use one of these commands: 58 59 rm -- -foo 60 61 rm ./-foo 62 Regards, - Robert