You are not logged in.

#1 2008-05-28 21:29:32

kadath
Member
Registered: 2008-05-28
Posts: 6

Linux Filename Rules

Long time lurker, first time poster here.

I'm curious about how everyone here handles filenames in Linux. I've read a few articles online discussing proper filenaming conventions in Linux (such as this one and this one).

Currently I have some files/directories with spaces, parentheses and brackets in their filenames. Is it best practice to use underscores instead of spaces, and avoid use of parentheses and brackets? It's also suggested to make all filenames and directory names lowercase.

How do you guys handle this subject?

Offline

#2 2008-05-28 21:34:07

skymt
Member
Registered: 2006-11-27
Posts: 443

Re: Linux Filename Rules

Spaces, brackets etc. are all just fine. They can be a bit inconvenient to refer to on the command line, but that's not an issue if you've gotten into the habit of quoting everything anyway.

Offline

#3 2008-05-28 21:36:15

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: Linux Filename Rules

skymt wrote:

Spaces, brackets etc. are all just fine. They can be a bit inconvenient to refer to on the command line, but that's not an issue if you've gotten into the habit of quoting everything anyway.

Offline

#4 2008-05-29 04:23:52

xd-0
Member
From: Sweden
Registered: 2007-11-02
Posts: 327
Website

Re: Linux Filename Rules

I hate underscores in filenames. If you treat space just like any other sign, you will quickly learn how to use it in scripts, terminals etc. And with tab-completion you will seldom notice it in cli. That said, if you use a graphical filemanager you will never notice it, but you will notice if all your filenames have underscores in them.

Offline

#5 2008-05-29 04:25:37

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,410
Website

Re: Linux Filename Rules

If your system works for you, then there is no point changing it.

Offline

#6 2008-05-29 04:29:56

kadath
Member
Registered: 2008-05-28
Posts: 6

Re: Linux Filename Rules

Alright, thanks for the advice guys.

Offline

#7 2008-05-29 08:03:49

robmaloy
Member
From: Germany
Registered: 2008-05-14
Posts: 263

Re: Linux Filename Rules

i never use spaces or brackets, because they always funk up bash scripts (or i'm too stupid to write proper scripts hmm)


☃ Snowman ☃

Offline

#8 2008-05-29 08:40:00

Barrucadu
Member
From: York, England
Registered: 2008-03-30
Posts: 1,158
Website

Re: Linux Filename Rules

robmaloy wrote:

i never use spaces or brackets, because they always funk up bash scripts (or i'm too stupid to write proper scripts hmm)

There is a simple way around that:

cd "/home/blah/Funky Dire(tory Name/"

I tend to use all lower-case filenames, and have a very strict directory structure and organisational method.

Last edited by Barrucadu (2008-05-29 08:41:07)

Offline

#9 2008-05-29 16:33:39

Zepp
Member
From: Ontario, Canada
Registered: 2006-03-25
Posts: 334
Website

Re: Linux Filename Rules

Barrucadu wrote:
robmaloy wrote:

i never use spaces or brackets, because they always funk up bash scripts (or i'm too stupid to write proper scripts hmm)

There is a simple way around that:

cd "/home/blah/Funky Dire(tory Name/"

I tend to use all lower-case filenames, and have a very strict directory structure and organisational method.

Or just escape those types of characters properly

cd /some\ directory\ with\ spaces/

Same thing for brackets and other special characters in filenames.

As for naming convention, use whatever you like on your system tongue.

Offline

#10 2008-05-29 19:30:33

skymt
Member
Registered: 2006-11-27
Posts: 443

Re: Linux Filename Rules

And as for Bash scripting:

$ cat ~/bin/test.sh
#!/bin/bash
ls "$1"
for str in "$@" ; do
    echo "$str"
done
$ test.sh "~/Strange Directory" "Foo Bar" "Baz Bin"
<contents of ~/Strange Directory>
Foo Bar
Baz Bin

Last edited by skymt (2008-05-29 19:30:42)

Offline

#11 2008-05-29 19:46:51

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: Linux Filename Rules

The only times I tend to put spaces in my directory names is when they're titles, otherwise I tend to keep the names short and with as few words as possible, hence negating the need for spaces.

However, I find them cumbersome, because I use the cmdline quite a bit, and when I do 'ls', the output is hard to read because of the spaces.  heh

Offline

#12 2008-06-02 04:37:44

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: Linux Filename Rules

There are no rules big_smile

On servers, I stick with all lower case, or camel-case in some instances. No spaces.

phillips@bundaberg:/home/phillips$ ls
bash-3.2.tar.gz     c          dead.letter  fs.xfs        horror.part3  id_dsa.pub  linux-0.01.tar.gz  mnt.ext3  scripts
black_and_white.ps  clock.sh   fs.ext3      horror.part1  horror.part4  iSearch     linux1.0           mnt.jfs   version-check.sh
burn-cache          colour.ps  fs.jfs       horror.part2  iBrigade      linux0.01   linux-1.0.tar.gz   mnt.xfs   wikipedia_replication

(Go the Linux 0.01!!)

On my desktop, I use "Windows" style with spaces and whatever else I feel like using because Linux will let me use more characters than Windows! big_smile  This only causes problems when trying to work with Windows, which my desktop doesn't so it's all good big_smile

fukawi2@phil-desktop:~$ ls
Activ Rally Sport               Download               Media                           TXT's
Downloads                       Music                  Templates                       Firefox_wallpaper.png
Total Annihilation.tar.bz2      Archive                Games                           Network             
Videos                          Audio51                Gnome Customization             Visual Basic
nohup.out                       Pictures               Desktop                         Images
Production Scripts              Documents              Installers                      Public
scripts

Offline

#13 2008-06-02 06:37:35

mintcoffee
Member
From: Waterloo, ON
Registered: 2007-10-05
Posts: 120
Website

Re: Linux Filename Rules

TOTAL ANNIHILATION! That was one sweet game... I sure miss Boneyards haha

@lucke: I see you what you did there.... wink


Arch on a Thinkpad T400s

Offline

#14 2008-06-02 06:40:18

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: Linux Filename Rules

mintcoffee wrote:

TOTAL ANNIHILATION! That was one sweet game... I sure miss Boneyards haha

Oh yeah big_smile
Blows that Cavedog went bust sadyikes

Offline

#15 2008-06-02 06:48:53

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: Linux Filename Rules

I find it's more of a challenge to avoid alphanumeric characters. Using filenames like &(@(@@><$, :-[ or ...... just plain looks cooler.

Last edited by iphitus (2008-06-02 06:49:22)

Offline

#16 2008-08-04 06:12:44

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: Linux Filename Rules

You goose tongue

Offline

#17 2008-08-04 12:00:51

ScriptDevil
Member
From: In Front of My PC
Registered: 2006-04-06
Posts: 253

Re: Linux Filename Rules

IAlwaysCamelCaseMyFilesAndFolders


Be yourself, because you are all that you can be

Offline

#18 2008-08-04 13:38:08

Stefan Husmann
Member
From: Germany
Registered: 2007-08-07
Posts: 1,391

Re: Linux Filename Rules

I do not like spaces. They are ok on Linux but if you have to share them with other, less modern unix like OS's you can get in trouble. I like underscores.

Offline

Board footer

Powered by FluxBB