shell script
Dear all
how can i create a folder of name "New Folder" using shell script. I tried "mkdir /mnt/ide4/New\ Folder" But i get only folder as New created not New Folder Please help. With Regards, deepti |
Well either of these should work
Code:
mkdir New\ Folder Code:
mkdir some/other/dir/New\ Folder 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.
Linux Archive |
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. |
Quote:
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. |
Quote:
I don't want to start a discussion, I just wanted to say that this advice: Quote:
Quote:
|
OP,
ALL of the following worked on my MEPIS 6.0 system: Code:
mkdir -p t/new\ folder1 Yes, please do ... Quote:
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. |
All times are GMT -5. The time now is 12:13 AM. |