Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 10-28-2005, 02:20 PM   #1
Registered: Dec 2004
Distribution: Zenwalk/Slackware
Posts: 98

Rep: Reputation: 15
mkdir "-folder name-"

how do i make directory named "-daily backup-",
i tried with escaping characters ("\-daily backup\-") but also dont work
how do i escape "-" looks like mkdir is seeing it as an option
Old 10-28-2005, 02:28 PM   #2
Registered: Aug 2003
Location: Akron, OH
Distribution: SuSE 8.2, Slackware current, OpenBSD 3.5-3.8, Fedora Core 2
Posts: 400

Rep: Reputation: 30
I'll venture to say that I don't think you can start either a filename or a directory with a '-' character. As you mentioned, any attempt to escape the character is simpy ignored by the mkdir command. Now, you COULD use the underscore character instead, but that may not help you if you are dead set on using a dash.
Old 10-28-2005, 02:37 PM   #3
Registered: Oct 2005
Location: Oxford, UK
Distribution: Debian Etch (w/ dual-boot XP for gaming)
Posts: 282

Rep: Reputation: 31
You can in fact start a file with a hyphen - it's just that Linux assumes if you use it in the ways you've suggested, that you're trying to specify an option. And it does so even if you escape it with quote marks, or bashslashes, or whatever. The trick is to use a double hyphen "--" to specify the end of options. Thus
mkdir -- "-daily backup-"
will work, and the quotes are only necessary because of the space - "mkdir -- -daily\ backup-" will work just as well, as does "touch -- -foo", etc.

You can also prefix the filename with the director it's contained in - so
mkdir "./-daily backup-"
works just as well. It's personal preference as to which one you use/remember!

Last edited by Dtsazza; 10-28-2005 at 02:40 PM.
Old 10-29-2005, 03:46 AM   #4
Registered: Dec 2004
Distribution: Zenwalk/Slackware
Posts: 98

Original Poster
Rep: Reputation: 15


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
"rm -rf /tmp", now Evolution shows "(no folder displayed" Ed-MtnBiker Linux - Software 7 04-10-2006 04:05 PM
"Mount" a folder into my ftp folder ? 0001001 Linux - General 3 11-27-2005 04:23 AM
mkdir ../binutils-build gives me "Permission Denied"!!! matthewa Linux From Scratch 16 06-29-2005 07:00 AM
Mandrake 10 "mount smbfs" the win2000 folder from vmware error wuyeguo Mandriva 1 03-19-2004 06:20 PM
"mkdir: cannot create directory `foo': Read-only file system" on FAT32 maddes Linux - Hardware 1 11-26-2003 06:19 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:27 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration