LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 05-11-2006, 09:25 AM   #1
soldan
Member
 
Registered: Feb 2006
Distribution: slackware 11
Posts: 110

Rep: Reputation: 15
file naming convention


hello, im wondering which way is best to name files with spaces in them,as linux doesnt like whitespace (if thats the correct terminology), ive seen that some people use a single dot, is this the generally accepted method? (so for example 'live.in.budapest.2006' ?
 
Old 05-11-2006, 09:26 AM   #2
meng
Member
 
Registered: Apr 2005
Location: Rochester, MN
Distribution: Ubuntu 7.04
Posts: 127

Rep: Reputation: 15
The underscore _ is a popular substitution.
 
Old 05-11-2006, 10:11 AM   #3
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,544
Blog Entries: 4

Rep: Reputation: 57
Who doesn't like whitespace?

Code:
cd some\ dir\ with\ spaces
cd "some other dir with spaces"
 
Old 05-11-2006, 10:18 AM   #4
ethics
Senior Member
 
Registered: Apr 2005
Location: London
Distribution: Arch - Latest
Posts: 1,522

Rep: Reputation: 45
Whitespaces are very possible, but can be a pain (auto tab completion makes it much easier

I use underscores, never got into . although it makes amarok file/tag editing easier
 
Old 05-11-2006, 10:28 AM   #5
geeman2.0
Member
 
Registered: Feb 2005
Location: Ontario, Canada
Distribution: Gentoo, Slackware
Posts: 345

Rep: Reputation: 30
I personally can't stand names like some\ file\ with\ spaces\ because on the CLI it makes it harder to visually separate the file names from the options/arguments.

I prefer using . instead of _ is slightly easier to type because it saves you pressing the shift key and is easier to reach.
But as said earlier, tab completion makes this kind of a moot point.
Even better is to think of a more succinct name for the file which doesn't require spaces at all.
 
Old 05-11-2006, 10:37 AM   #6
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Rep: Reputation: 61
It depends on the files in question. As noted, Linux doesn't like the spaces very much, but it can deal with them. I never leave spaces in a text file name, a script, or simlar working files. OTOH, I would not even consider naming an .mp3 file without the spaces.
 
Old 05-11-2006, 11:31 AM   #7
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591

Rep: Reputation: 79
Quote:
Originally Posted by geeman2.0
I personally can't stand names like some\ file\ with\ spaces\ because on the CLI it makes it harder to visually separate the file names from the options/arguments.

I prefer using . instead of _ is slightly easier to type because it saves you pressing the shift key and is easier to reach.
But as said earlier, tab completion makes this kind of a moot point.
Even better is to think of a more succinct name for the file which doesn't require spaces at all.
Funny on my french keyboard, the . needs the shift key. - doen't though.
What about replacing " " with "[space]" ?
Actually linux has nothing to do with file naming support. The file system does. You can use linux on ext2, ext3, raiser, nfs, sshfs, vfat, or whatever (even ntfs!). The space support is different depending on the file system, not linux.

Last edited by Agrouf; 05-11-2006 at 11:34 AM.
 
Old 05-11-2006, 11:34 AM   #8
hockeyman_102
Member
 
Registered: Apr 2006
Location: Washington
Distribution: Suse, CentOS, Ubuntu
Posts: 124

Rep: Reputation: 15
Thats one great thing about linux - you can use '.' or '_' or '\ ' in your filename and it really doesn't care. It seems to be personal preference to me. I usually use '_' with folders and '.' with files.
 
Old 05-11-2006, 10:49 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
The usual convention in Unix is underscores between name parts, but '.' between the name and the final extension (if there is one) eg:
my_shell_script.sh
Note that binary executables do NOT have an extension eg
my_executable
Technically, for script type files eg shell (.sh), perl (.pl) etc, the extension is not needed as the relevant exe ie /bin/bash or /usr/bin/perl will read and run the file regardless.
Personally I always use extensions (except for binaries) for ease of reading.
 
Old 05-12-2006, 10:37 AM   #10
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 30
The kernel itself doesn't care about spaces. The only characters you can't use in a filename are a nul and a /, for obvious reasons, though particular filesystems might have further restrictions.

As noted, the standard convention is an underscore, though I sometimes use a hyphen. Ultimately, it doesn't really matter, use whatever is more readable for you.
 
Old 05-15-2006, 09:23 AM   #11
soldan
Member
 
Registered: Feb 2006
Distribution: slackware 11
Posts: 110

Original Poster
Rep: Reputation: 15
thanks everyone
 
Old 05-15-2006, 11:14 AM   #12
BinJajer
Member
 
Registered: Sep 2005
Location: Warsaw, Poland
Distribution: Slackware 10.2, Caldera OpenLinux 3.1, Corel Linux (Thanks xhi!), Debian GNU/HURD etc...
Posts: 296
Blog Entries: 1

Rep: Reputation: 30
Quote:
Originally Posted by Agrouf
Actually linux has nothing to do with file naming support. The file system does. You can use linux on ext2, ext3, raiser, nfs, sshfs, vfat, or whatever (even ntfs!). The space support is different depending on the file system, not linux.

Hmm... right. But how on earth did you get Lin to even boot up on ntfs? I only got it to load the initrd and do some preliminary hw detection.
 
Old 05-15-2006, 11:35 AM   #13
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 55
In the real linux terminology, you don't have "extensions" you have "suffixes"
And there was also a more or less standard that you only put an .sh suffix when there is not the shebang (#!/bin/sh) on a first line
. myscript.sh
./myscript

Its a detail but .. its important

Last edited by nx5000; 05-15-2006 at 11:36 AM.
 
Old 05-15-2006, 12:11 PM   #14
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591

Rep: Reputation: 79
Quote:
Originally Posted by BinJajer
Hmm... right. But how on earth did you get Lin to even boot up on ntfs? I only got it to load the initrd and do some preliminary hw detection.
Well, I didn't.
I just thought it was theorically possible, but I'm not sure about that and that's not a piece of cake anyway.
Did you seriously try it? That's cool man.
I suspect it stops when it has something to write, as ntfs write is not that good as of now. Did you activate ntfs writing when compiling the kernel?
 
  


Reply


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
naming convention for dual boot boxen blue penguin General 4 02-25-2006 05:10 PM
usb naming convention hoover93 Linux - Hardware 5 10-19-2005 11:18 PM
mail server the naming naming convention problem kashan Linux - Newbie 0 07-16-2004 03:08 PM
A small question in naming convention mnguyen Linux - Software 1 04-17-2004 04:14 AM
What is the naming convention for files in rcX.d? roshko Linux - Newbie 2 09-01-2003 05:41 PM


All times are GMT -5. The time now is 08:36 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration