I have a one column text file (dates.txt) and I want to create a stack of directories named after the dates elements.
How can I interpret it in bash?
I have a one column text file (dates.txt) and I want to create a stack of directories named after the dates elements.
How can I interpret it in bash?
 
    
     
    
    Read in the contents of the file, and make directories for each entry in your data file, like this:
while IFS= read -r dat; 
do 
   mkdir "$dat"
done < dates.txt
 
    
    xargs mkdir < dates.txt
xargs will read the lines of its stdin, and append the lines to the given command. This will minimize the number of times mkdir is invoked.
 
    
    With mapfile (Bash 4.0 or newer):
mapfile -t names < dates.txt && mkdir "${names[@]}"
This reads the lines into an array names and then calls mkdir with the expanded, properly quoted array elements as arguments.
The -t is required to remove the newline from the end of each element.
