LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-19-2009, 03:24 PM   #1
ootawata
LQ Newbie
 
Registered: Jan 2007
Distribution: Fedora
Posts: 20

Rep: Reputation: 0
Are there invalid directory characters?


What is illegal to have in a directory path? I've noticed that you can do:

Code:
mkdir '!@#$%^&*()-_=+[]{};:,.<>? '
I can't seem to get a path with ', ", or / in this. I tried escape characters but I can't get them to be with the other characters. For example, this works:

Code:
mkdir "'\"\/"
but I can't do

Code:
mkdir "!@#$"
The above gives this error:

Code:
bash: !@#$: event not found
I know that having symbols for directory names is...silly, but I'm curious.
 
Old 08-19-2009, 03:40 PM   #2
Nevahre
LQ Newbie
 
Registered: Aug 2009
Posts: 21

Rep: Reputation: 16
Nothing is illegal I think, and mostcan be done:

mkdir '!@#$'
/tmp/Tets $ ls -l
total 4
drwxr-x--- 2 nevahre users 4096 Aug 19 22:37 !@#$

I don't think its wise to use anything else than: A-Z a-z 0-9 _-. (maybe 1 or 2 more).
 
Old 08-19-2009, 04:13 PM   #3
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Rep: Reputation: 234Reputation: 234Reputation: 234
A rule of thumb is to use:

A-Z
a-z
0-9
_ (underscore)
- (hyphen)
+ (plus)
space
. (dot)

For the best compatibility is better to avoid spaces and use underscores instead.

I have nice MP3 collection. When I prepared it I stated that Linux doesn't accept / in file's names because that character stands in Linux for subdirectory so I used instead \.

Recently I shared my MP3 collection with my friend. I use Slackware with ReiserFS. He has external hard disk with FAT32.

During copying files I observed that FAT32 doesn't accept some characters in file's names. It doesn't accept \ because that character stands in Windows for subdirectory. I tried | instead but Windows doesn't accept it too for some reason. So finally I used -. Instead of : I was forced to use ;. And finally I was forced to give " up.

So instead of use:

04 Evolution of a Pearl (Part 1/Part 2).mp3
04 Evolution of a Pearl (Part 1\Part 2).mp3
04 Evolution of a Pearl (Part 1|Part 2).mp3
11 Why?.mp3
01 Ghosts: First Variation.mp3
09 Take the "A" Train.mp3

I was forced to use:

04 Evolution of a Pearl (Part 1-Part 2).mp3
11 Why.mp3
01 Ghosts; First Variation.mp3
09 Take the A Train.mp3

In MP3 file's names I use also those characters:

!
#
%
&
'
(
)
,
;
=
[
]
 
Old 08-20-2009, 12:17 PM   #4
ootawata
LQ Newbie
 
Registered: Jan 2007
Distribution: Fedora
Posts: 20

Original Poster
Rep: Reputation: 0
I found out that you cannot use "/" or "/000" (it may have been \000). Not sure why the latter is not allowed.
 
Old 08-20-2009, 10:29 PM   #5
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by ootawata View Post
I found out that you cannot use "/" or "/000" (it may have been \000). Not sure why the latter is not allowed.
"/" is hard coded in the kernel as directory separator, so it's can't be part of the name.
"\000" - mkdir (and all other file-name related syscalls) expect to get null terminated string.
So \000 considered as "end of the string"
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Linux to remove directory containing invalid windows filenames? ellentk Linux - Newbie 7 06-11-2009 09:23 AM
invalid integer value on a directory j-me Linux - Newbie 5 04-27-2009 07:13 PM
Need to rename files and folders with invalid characters in the names laureynsr Linux - Newbie 5 04-01-2009 03:13 PM
spaces and odd characters in directory name in bash? babag Programming 1 04-02-2008 03:28 PM
Courier: Maildir invalid (no 'cur' directory) binjured Linux - General 1 06-11-2006 11:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:15 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