linux-admin.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* A Good Question.
@ 2004-03-31  5:55 Scott@Charter
  2004-03-31  6:28 ` Jeff Woods
  2004-03-31  6:33 ` Bostjan Skufca (at) domenca.com
  0 siblings, 2 replies; 6+ messages in thread
From: Scott@Charter @ 2004-03-31  5:55 UTC (permalink / raw)
  To: Linux-Admin-Group

[-- Attachment #1: Type: text/plain, Size: 338 bytes --]

1. How would you create a file named "--help"?
I actually created a the file by doing something like touch test >>--help.
But I think there is a "proper" way to create it?


2. How would you remove a file named "--help"?



Scott D. Smallsreed
3030 Chipmunk Dr.
Washoe Valley, NV  89704
775.849.8411 Hm
775.849.8412 Fax
775.722.7773 Cell

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Scott Smallsreed.vcf --]
[-- Type: text/x-vcard; name="Scott Smallsreed.vcf", Size: 366 bytes --]

BEGIN:VCARD
VERSION:2.1
N:Smallsreed;Scott
FN:Scott Smallsreed
TEL;HOME;VOICE:775-849-8411
TEL;HOME;FAX:775-849-8412
ADR;HOME:;;3030 Chipmunk Dr.;Washoe Valley;Nevada;89704;US
LABEL;HOME;ENCODING=QUOTED-PRINTABLE:3030 Chipmunk Dr.=0D=0AWashoe Valley, Nevada 89704=0D=0AUS
EMAIL;PREF;INTERNET:scott.smallsreed@mindspring.com
REV:20040331T055544Z
END:VCARD

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: A Good Question.
  2004-03-31  5:55 A Good Question Scott@Charter
@ 2004-03-31  6:28 ` Jeff Woods
  2004-03-31 12:54   ` Nico Schottelius
  2004-03-31 13:02   ` Glynn Clements
  2004-03-31  6:33 ` Bostjan Skufca (at) domenca.com
  1 sibling, 2 replies; 6+ messages in thread
From: Jeff Woods @ 2004-03-31  6:28 UTC (permalink / raw)
  To: Scott@Charter; +Cc: Linux-Admin-Group

At 3/30/2004 09:55 PM -0800, Scott@Charter wrote:
>1. How would you create a file named "--help"?
>I actually created a the file by doing something like touch test >>--help.
>But I think there is a "proper" way to create it?

Commands that interpret --help as an option should (but might not) support 
-- to indicate "end of options" and all arguments following are to be 
interpreted as "non-option".  Which means if the command takes a list of 
files as arguments you can force it to recognize arguments beginning with - 
as files by preceeding them with --.  For example, the following 
hypothetical command line:

         $ somecommand --someoption --another -- --justafile --notanoption 
--help

should treat --someoption and --another as options, but --justafile 
--notanoption and --help should be treated as files (or whatever 
somecommand wants to use those arguments for).

If touch tries to interpret --help as an option, then "touch -- --help" 
should treat --help as a filename.

>2. How would you remove a file named "--help"?

Likewise, "rm -- --help" should remove filename --help

You could also use a partial or absolute path to the file, e.g.:

         $ touch ./--help
or
         $ touch $PWD/--help

If in doubt, sticking "./" in front of a filename in the current directory 
can simplify ornery cases like this.

Bonus problems:
How to create and delete file names with spaces or control characters?
How about slashes  (not as a directory delimiter) in the filename?

--
Jeff Woods <kazrak+kernel@cesmail.net> 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: A Good Question.
  2004-03-31  5:55 A Good Question Scott@Charter
  2004-03-31  6:28 ` Jeff Woods
@ 2004-03-31  6:33 ` Bostjan Skufca (at) domenca.com
  1 sibling, 0 replies; 6+ messages in thread
From: Bostjan Skufca (at) domenca.com @ 2004-03-31  6:33 UTC (permalink / raw)
  To: linux-admin

touch ./--help
rm ./--help

Best regards,
Bostjan

On Wednesday 31 of March 2004 07:55, Scott@Charter wrote:
> 1. How would you create a file named "--help"?
> I actually created a the file by doing something like touch test >>--help.
> But I think there is a "proper" way to create it?
>
>
> 2. How would you remove a file named "--help"?
>
>
>
> Scott D. Smallsreed
> 3030 Chipmunk Dr.
> Washoe Valley, NV  89704
> 775.849.8411 Hm
> 775.849.8412 Fax
> 775.722.7773 Cell


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: A Good Question.
  2004-03-31  6:28 ` Jeff Woods
@ 2004-03-31 12:54   ` Nico Schottelius
  2004-03-31 13:02   ` Glynn Clements
  1 sibling, 0 replies; 6+ messages in thread
From: Nico Schottelius @ 2004-03-31 12:54 UTC (permalink / raw)
  To: Jeff Woods; +Cc: Scott@Charter, Linux-Admin-Group

[-- Attachment #1: Type: text/plain, Size: 614 bytes --]

Jeff Woods [Tue, Mar 30, 2004 at 11:28:28PM -0700]:
> [...] 
> Bonus problems:
> How to create and delete file names with spaces or control characters?

with spaces: rm "file with spaces" (quoted as one arg)
with control charaters: perpaps with their octal representation?

> How about slashes  (not as a directory delimiter) in the filename?

slashes aren't iirc allowed in filenames on unix filesystems.
(and wouldn't make any sense either, as they are defined _as_ limiter,
you cannot escape them)


Nico

ps: I don't think any FAT/NTFS version can handle slashes either. But this is a guess.

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: A Good Question.
  2004-03-31  6:28 ` Jeff Woods
  2004-03-31 12:54   ` Nico Schottelius
@ 2004-03-31 13:02   ` Glynn Clements
  2004-03-31 20:32     ` Bradley Hook
  1 sibling, 1 reply; 6+ messages in thread
From: Glynn Clements @ 2004-03-31 13:02 UTC (permalink / raw)
  To: Jeff Woods; +Cc: Linux-Admin-Group


Jeff Woods wrote:

> Bonus problems:
> How to create and delete file names with spaces or control characters?

Use single quotes; within single quotes, all characters are treated
literally, except for the terminating quote. If the filename contains
any single quotes, use '\'' (quote, backslash, quote, quote), e.g.

	rm 'foo'\''bar'

will remove a file called foo'bar.

However, note that this issue is due to the shell; it doesn't apply
when passing arguments directly via e.g. execve(). OTOH, filenames
which look like options are due to the command itself.

> How about slashes  (not as a directory delimiter) in the filename?

Not possible. A filename cannot contain a slash; this is enforced by
the kernel. If you encounter a filename which contains a slash, the
filesystem is corrupted.

-- 
Glynn Clements <glynn.clements@virgin.net>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: A Good Question.
  2004-03-31 13:02   ` Glynn Clements
@ 2004-03-31 20:32     ` Bradley Hook
  0 siblings, 0 replies; 6+ messages in thread
From: Bradley Hook @ 2004-03-31 20:32 UTC (permalink / raw)
  To: linux-admin

For spaces:
  #touch my\ test
  #touch 'my test'

  #less my\ test
  #less 'my test'

For backslashes:
  #touch my\\test
  #touch 'my\test'

  #less my\\test
  #less 'my\test'

Forward slashes aren't allowed by the kernel.

~Brad

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-03-31 20:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-31  5:55 A Good Question Scott@Charter
2004-03-31  6:28 ` Jeff Woods
2004-03-31 12:54   ` Nico Schottelius
2004-03-31 13:02   ` Glynn Clements
2004-03-31 20:32     ` Bradley Hook
2004-03-31  6:33 ` Bostjan Skufca (at) domenca.com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).