Linux Tips: File Naming


If you are coming from the world of Windows you are pretty much used to naming a file whatever. You could have a file named “This Is My File And This File Is Called Meh.doc” In the world of Windows you wouldn’t have any problem with that file. In the world of Linux you might run across some issues.


Of course you could open up Nautilus, Dolphin, Thunar or any other file manager tool, double click on that .doc file, and start working on it in your word processor of choice. But what if you wanted (or needed) to move that file via command line? What would you do?
If you attempted to issue the command:
mv ~/Documents/This Is My File And This File Is Called Meh.doc ~/
you would see:
mv: cannot stat `This’: No such file or directory
mv: cannot stat `Is’: No such file or directory
mv: cannot stat `My’: No such file or directory
mv: cannot stat `File’: No such file or directory
mv: cannot stat `And’: No such file or directory
mv: cannot stat `This’: No such file or directory
mv: cannot stat `File’: No such file or directory
mv: cannot stat `Is’: No such file or directory
mv: cannot stat `Called’: No such file or directory
mv: cannot stat `Meh.doc’: No such file or directory
Now if you started typing the command:
mv ~/Documents/This
and you hit the Tab key bash would complete the file name, only it would look like:
This\ Is\ My\ File\ And\ This\ File\ Is\ Called\ Meh.doc
at which point you could finish typing out the command with sucessful results.
To avoid this all together, don’t use spaces in file names when using Linux. If you need to separate words use either a “-” or an “_” to separate words like so:
This_Is_My_File_And_This_File_Is_Called_Meh.doc
Of course the above file name is rather cumbersome. But you get the point.
No spaces in file names under the Linux operating system.

0 comments:

Post a Comment

 
Twitter Bird Gadget