create directory

Posted on 2005-05-10
Last Modified: 2012-05-05
How can I create directory? I have a 200 directory that i want to create. All of directory name that I want to create is in the file name "list".
Please help
Question by:teera
    LVL 23

    Expert Comment

    mkdir (dirname)

    What does "list" look like?

    if it's a list of just directory names one per line, you could use something like

    cat list |xargs mkdir

    to make your directories

    Author Comment

    it show    
    xargs: un match single qouat

    List file is like this

    Aloha Resort & Spa
    Al's Hut Bungalow
    Al's Resort
    Amadeus Bungalow
    Amari Palm Reef Resort
    Amity Bungalow
    Anchor House Bungalow
    Anong Villa
    Ar-An Resort
    Arayaburi Boutique Resort
    Aree Bungalow
    Ark Bar Garden Beach Resort
    Axolotl Village
    Baan Chaweng Resort
    Baan Haad Ngam Boutique Resort & Spa
    LVL 45

    Assisted Solution

    The error might be due to the single ' in Al's

    You need to preprocess the file to escape all ' with a \

    sed "s/'/\\\'/" name >
    LVL 23

    Accepted Solution

    Special characters in the directory names like space and '  (single quote,
    or apostrophe) throw it off and need to be escaped.

    try  starting with:

    cat list |sed "s/ /\\ /g;  s/'/\\'/g" |xargs mkdir
    LVL 4

    Assisted Solution

    just use quotes or  around each line - it covers everything (except quotes and $,! )...

    to modify Mysidia's version (^and $ are start/end of each line):
    cat ../list |sed -e  "s/^/\"/g;s/$/\"/g" | xargs mkdir  

    to escape quotes too:
    cat ../list |sed -e  "s/\"/\\\"/g; s/^/\"/g;s/$/\"/g"  | xargs mkdir  

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    In this tutorial I will explain how to make squid prevent malwares in five easy steps: Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-…
    I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now