LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 10-28-2005, 02:20 PM   #1
xrado
Member
 
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
Tino27
Member
 
Registered: Aug 2003
Location: Akron, OH
Distribution: Slackware 14.2-stable, Ubuntu 16.04 LTS
Posts: 401

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
Dtsazza
Member
 
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
Code:
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
Code:
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
xrado
Member
 
Registered: Dec 2004
Distribution: Zenwalk/Slackware
Posts: 98

Original Poster
Rep: Reputation: 15
thx!
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:45 PM.

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