LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Puppy
User Name
Password
Puppy This forum is for the discussion of Puppy Linux.

Notices


Reply
  Search this Thread
Old 12-06-2014, 01:59 AM   #1
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Rep: Reputation: 169Reputation: 169
Un-allowed characters in filenames


This is incorrect. For example "&" is not allowed in directory names.

Code:
Spaces, and indeed every character except / and NUL, are allowed in filenames.
Are there any others ?

Last edited by Fixit7; 12-06-2014 at 04:26 PM.
 
Old 12-06-2014, 04:09 AM   #2
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Hi there,

Quote:
Originally Posted by Fixit7 View Post
For example "&" is not allowed in directory names.
says who? Okay, maybe there is some spec somewhere claiming this, but in practise, the '&' character works just fine in file and directory names. I'm using that quite frequently on ext2,3,4 file systems, and also on alien FAT and NTFS file systems. Never had a problem about this, and no fsck ever complained about this. But there may be other file systems that do make trouble with '&'.

However, there are some characters you'd better avoid (though it's possible to use them) as they may cause trouble in certrain scenarios, for example '%', '+', ':', '<', '>', '|'. Also I read occasionally that braces and square brackets are troublesome here and there, though they can be used if they are properly escaped on the command line.

Code:
Spaces, and indeed every character except / and NUL, are allowed in filenames.
I should think that the shell wildcard characters '*' and '?' are also strictly forbidden.

[X] Doc CPU
 
1 members found this post helpful.
Old 12-06-2014, 01:40 PM   #3
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
& does not work in Puppy 5.9.

It may work in other distros.
 
Old 12-06-2014, 02:32 PM   #4
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Quote:
Originally Posted by Fixit7 View Post
& does not work in Puppy 5.9.

It may work in other distros.
Which file system are you using? How are you trying to create the folder? I just created and deleted a directory with an ampersand in the name under Debian Sid on and ext4 partition no problem I also created a directory with the name & and that was fine too though, of course, I had to use quotes to create both with mkdir.
 
1 members found this post helpful.
Old 12-06-2014, 03:00 PM   #5
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,339

Rep: Reputation: Disabled
Quote:
Originally Posted by Fixit7 View Post
& does not work in Puppy 5.9.

It may work in other distros.
The set of disallowed characters is a limitation of the file system in question, not the distribution.

Applications and (especially) scripts may not escape and/or quote characters properly, and may therefore have trouble handling file names containing characters that must be escaped/quoted when used in a shell. Try this in a terminal window:
Code:
echo This will probably work > "&.txt"
 
Old 12-06-2014, 04:30 PM   #6
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
I wasn't using the quotes when making the directory.

:-)
 
Old 12-06-2014, 04:33 PM   #7
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Quote:
Originally Posted by Fixit7 View Post
I wasn't using the quotes when making the directory.

:-)
That would certainly explain it . If you don't then, as you have seen, the symbol is interpreted by the shell instead of as part of the file name.
All the above said personally I tend to avoid creating directories and files with any characters which could cause this kind of problem, including ampersands and spaces. I do have some directories with spaces and ampersands in the names but only because I'm too lazy to change them in all the locations they are stored.
 
Old 12-08-2014, 04:03 AM   #8
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Quote:
Originally Posted by Doc CPU View Post
However, there are some characters you'd better avoid (though it's possible to use them) as they may cause trouble in certrain scenarios, for example '%', '+', ':', '<', '>', '|'. Also I read occasionally that braces and square brackets are troublesome here and there, though they can be used if they are properly escaped on the command line.


Where possible try and avoid ANY characters that need escaped, and also while spaces ARE allowed try and use _ instead. I've recently had to deal with file transfers using rsync & scp where applications designers decided to use Windows reserved characters as well as spaces, and even "::" in file names, this caused no end of problems when trying to escape things for use with SCP.


For anyone that's interested I ended up using this to "clean up" file names in a folder.


Code:
ls | while read -r FILE ; do
  mv -u "${FILE}" $(echo "${FILE}" | tr ' ' '_' | tr -d '[{}(),\!]' | tr ':' '_' | sed 's/__/_/g') 2>/dev/null
done
For anyone that's interested here's a link to what Windows considers invalid characters: http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

Last edited by TenTenths; 12-08-2014 at 04:07 AM. Reason: Added link to Win reference
 
Old 12-08-2014, 04:42 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
All characters except "/" are valid in native UNIX file system file and directory names and hence in native Linux file systems.

It is impossible (?) to create a file or directory with an ASCII NUL (value 0) in the name.

It is a matter of choice whether to avoid characters that are meaningful to the shell and hence which require care on the command line.
 
Old 12-08-2014, 11:30 AM   #10
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Hi there,

Quote:
Originally Posted by TenTenths View Post
Where possible try and avoid ANY characters that need escaped, and also while spaces ARE allowed try and use _ instead.
I disagree. While of course everybody should get happy their own way, my position is that file names should map real-world names as closely as possible. That's why I do encourage the use of spaces, ampersands, umlauts or punctuation marks where they're appropriate. However, I know there are some technical restrictions, partly by the file system, but more so by the software being involved, and I reluctantly accept them if there's no way of circumventing them. Escaping those offending characters is such a way of circumventing restrictions, and a compliant one at that.

I avoid the underline wherever possible - simply because I find it ugly.

Quote:
Originally Posted by TenTenths View Post
I've recently had to deal with file transfers using rsync & scp where applications designers decided to use Windows reserved characters as well as spaces, and even "::" in file names, this caused no end of problems when trying to escape things for use with SCP.
Hehe. Broken software ...
But seriously, some time ago I was totally at a loss: I tried to copy a file from a Linux box to a Windows box via Samba and Windows file sharing. This had worked well for a long time. But the Linux machine (Thunar, for that matter) kept telling me that the file couldn't be copied because of unsufficient access rights on the target computer. It took me quite some time (and a lot of double-checking of permissions and Samba settings) until I noticed that the file name had a colon ':' in it, which is forbidden in Windows. ;-)

Quote:
Originally Posted by catkin View Post
It is impossible (?) to create a file or directory with an ASCII NUL (value 0) in the name.
It is. And the very first reason is that the NUL character would be considered the end-of-string marker, so it cannot be part of a NUL-terminated string.

[X] Doc CPU
 
Old 12-08-2014, 11:44 AM   #11
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
I don't recall the details but I thinlk the reason the colon is not allowed is because it refers to a different stream which, if I recally correctly, was a function of NTFS which was never implemented fully.
 
Old 12-08-2014, 12:15 PM   #12
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Hi there,

Quote:
Originally Posted by 273 View Post
I don't recall the details but I thinlk the reason the colon is not allowed is because it refers to a different stream which, if I recally correctly, was a function of NTFS which was never implemented fully.
it's much more obvious and dates back to the stone age of DOS, where the colon was used to separate a device name (most frequently a drive letter) from the actual path or parameters. Windows has just dragged along that legacy ever since.

[X] Doc CPU
 
Old 12-08-2014, 12:39 PM   #13
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Quote:
Originally Posted by Doc CPU View Post
Hi there,



it's much more obvious and dates back to the stone age of DOS, where the colon was used to separate a device name (most frequently a drive letter) from the actual path or parameters. Windows has just dragged along that legacy ever since.

[X] Doc CPU
Are you sure? NTFS now allows characters which weren't possible with older file systems -- I think some accented characters may be allowed also from a vague recollection of dealing with German and Spanish file and "directory" names.
I did get the impression that either file streams were scrapped by MS due to time and cost restrictions or were only there due to NTFS being based upon previous work though the latter is probably me confusing it with Active Directory and LDAP.
Edit: oops, forgot the link:
http://support.microsoft.com/KB/105763

Last edited by 273; 12-08-2014 at 12:41 PM. Reason: Forgot the link to MS
 
Old 12-08-2014, 02:33 PM   #14
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Hi there,

Quote:
Originally Posted by 273 View Post
NTFS now allows characters which weren't possible with older file systems -- I think some accented characters may be allowed also from a vague recollection of dealing with German and Spanish file and "directory" names.
yes, that's true. But don't confuse things. Characters with codes >0x80 were allowed as part of "long file names" introduced in Windows 95. You may or may not remember that the consumer branch of Windows 4 (that is, 95, 98, and its downgrade ME) were two-pronged: Each file had a backward-compatible 8.3 file name with all the restrictions that ever existed (only uppercase letters, digits, and a very small set of punctuation characters), and optionally it had a long file name, which was very liberal right from the start.

There were a lot of problems about this; some programs saw a directory "Program Files", others saw "PROGRA~1", which was factually the same. Some even used the truncated short names and seemed to hope that they were linked to their long counterparts by some kind of magic. Well, it was a mess.

For quite some time, NTFS mimicked that behavior, and I think it's only since Windows 7 that MS dropped the legacy 8.3 file name scheme entirely.

Quote:
Originally Posted by 273 View Post
I did get the impression that either file streams were scrapped by MS due to time and cost restrictions or were only there due to NTFS being based upon previous work though the latter is probably me confusing it with Active Directory and LDAP.
I don't know anything about these alternate streams other than they exist in NTFS. I've never seen an application actually using them, never seen a convincing theory or explanantion what they're good for.

[X] Doc CPU
 
Old 12-08-2014, 03:01 PM   #15
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,339

Rep: Reputation: Disabled
Quote:
Originally Posted by Doc CPU View Post
I don't know anything about these alternate streams other than they exist in NTFS. I've never seen an application actually using them, never seen a convincing theory or explanantion what they're good for.
While anything can be stored in an NTFS Alternate Data Stream, they are most commonly used for storing metadata. For instance, when a file is downloaded from the Internet and saved on an NTFS volume, Windows will store information about the file's origin ("zone") in an ADS called "Zone.Identifier". In that sense, Alternate Data Streams can be considered the NTFS version of Extended Attributes (although NTFS supports POSIX Extended Attributes as well).

Being able to store and modify metadata without having to touch the actual contents of a file is very convenient, but unfortunately no standard for ADS metadata storage exists on the Windows platform, so except for the (very) few instances where the OS itself creates and maintains such streams, this doesn't really work across applications.

Also, The fact that this feature it tied to one specific file system probably hasn't helped in its adoption. Even ReFS didn't initially support ADS.
 
  


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
[SOLVED] Valid characters for filenames Jerry Mcguire Linux - General 4 10-28-2010 03:18 AM
Special characters in PAR2 filenames ricardisimo Linux - Newbie 3 07-16-2009 08:18 PM
Strip special characters from filenames General Linux - Software 1 05-14-2006 03:49 AM
Special characters in filenames gmartin Linux - General 2 01-05-2006 08:22 PM
sftp with filenames and weird characters Nevion Linux - Software 1 05-28-2004 05:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Puppy

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