Find the answer to your Linux question:
Results 1 to 5 of 5
1. I need guide on how to create a folder name from the text file with .txt format. 2. First, I call the function of reading the directory. 3. Then, ...
  1. #1
    Just Joined!
    Join Date
    Jun 2010
    Posts
    5

    Create folder name from the text file

    1. I need guide on how to create a folder name from the text file with .txt format.

    2. First, I call the function of reading the directory.

    3. Then, I dont know how to do.

    4. Finally, I close the directory

    This is my source code in perl

    ## read text.txt file ##
    open F, "from/$directory/text.txt";
    read F, $buf, 9999;
    close F;[/size]

    This source code is used to print the folder with date format like "ddmm" d stands for day and m stands for month
    if ($command =~ s/-O "(.*)"/-O "$websites\/$month\/$file"/)

    Instead, I want to have the name from text.txt to be folder name

  2. #2
    Linux Newbie theNbomr's Avatar
    Join Date
    May 2007
    Location
    BC Canada
    Posts
    150
    So, to rephrase your question: you have a text file containing records that are to be used as directory names, and the directories need to be created as read from that file?
    Please post a sample of the text file, using [CODE] tags.
    --- rod.
    Stuff happens. Then stays happened.

  3. #3
    Just Joined! shtromm's Avatar
    Join Date
    Jun 2010
    Posts
    31
    Roughly this way:

    Code:
    #!/bin/bash
    LetSee="ls -l "
    ExeCute=""
    
    cat DirList.txt | while read line; 
    do
       ExeCute=$LetSee${line};
       $ExeCute;
    done;

  4. #4
    Just Joined!
    Join Date
    Jun 2010
    Posts
    5
    Thanks for reply. Your rephrase is correct, it is what i wanted to tell. I will use the code u provided. If any problem, I reply u again. Thanks again.

  5. #5
    Linux Newbie theNbomr's Avatar
    Join Date
    May 2007
    Location
    BC Canada
    Posts
    150
    This might be cleaner. If the list of directory names is 'dirs.txt', and is formatted one directory name per line:
    Code:
    while read dirname; do mkdir -p $dirname; done < dirs.txt
    --- rod.
    Stuff happens. Then stays happened.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...