Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
If you don't use (double-)quotation marks, you need to use the escape character \ to escape the whitespace, but it's often easier to enclose the whole filename with (double)quotes.
EDIT: please edit your profile information and add there the operating system/distribution you are using; this helps answering your possibly distributio-specific questions.
You can also use the -p option with mkdir to create all interim directories. Using your example /mnt is likely to exist, but if /mnt/ide4 has not been created yet, then it will be created before "New Folder". This is useful in shell scripts, where directory structures can change among sessions.
Just FYI, many Linux cmds have problems with spaces in dirnames/filenames, unless you take special precautions, so don't do that (if possible).
It'll save you a lot of grief later.
As an example, <space> is often used as the delimiter between parameters.
Just FYI, many Linux cmds have problems with spaces in dirnames/filenames, unless you take special precautions, so don't do that (if possible).
False. They handle it as well as it can be done.
So, how do you propose that this should be handled? Spaces are always interpreted as separators for the different arguments of a given command, unless they are quoted. It's not only the correct and easiest way to do it, it's also the way it's been for ages. It works ok as long as you know how to use it.
Just learn to use the escape backslash or quote the thing adequately, windows is the same on that regards, except for the fact that windows users never use the command line so they don't notice (or they use the stupid filena~1.ext DOS-like form, which is one of the dumbest things ever).
As I said "unless you take special precautions," ie you have to use backslash and or use quotes everywhere.
It just gets messy, esp in one liners/nested cmds etc.
If you look around, you'll find most scripts (not just on LQ) use the default mode ie assume no spaces in filenames.
I never said Unix/Linux can't do it, it can. Its just more work.
As I said "unless you take special precautions," ie you have to use backslash and or use quotes everywhere.
It just gets messy, esp in one liners/nested cmds etc.
If you look around, you'll find most scripts (not just on LQ) use the default mode ie assume no spaces in filenames.
I never said Unix/Linux can't do it, it can. Its just more work.
If you search a bit, you will find thousands of topics on the net advising you to do so. ALL the variables should be quoted to avoid problems. It's just common sense. You could forbid spaces in file names... It's the only alternative: to go back to the DOS naming scheme.
I don't want to start a discussion, I just wanted to say that this advice:
Quote:
always quote your variables and filenames unless you are certain that they don't have any special character on them
Is much better and more practical than this other one:
Quote:
don't use space on your filenames
In a modern system where we see lots even thousands of files every day with spaces on them.
OP,
ALL of the following worked on my MEPIS 6.0 system:
Code:
mkdir -p t/new\ folder1
mkdir -p t/'new folder2'
mkdir -p "t/new folder3"
cd t
mkdir new\ folder4
mkdir 'new folder5'
mkdir "new folder6"
cd ..
ls t |less
I wonder if the lack of the "-p" option is the cause of your problem.
Yes, please do ...
Quote:
Originally Posted by b0uncer
...edit your profile information and add there the operating system/distribution you are using; this helps answering your possibly distributio-specific questions.
Spaces_in_filenames
I am a latecomer to *nix, so I can't speak w/ the authority I'd like; but I believe the old Unix way is to use underscores instead of spaces.
Yes, there are ways around the problems of handling spaces, but life is so much easier if you don't have to bother. I have even written code to scan such spaces & automatically replace them -- it was especially useful for (directories full of) .mp3's.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.