Reputation: 4774
I have a txt
file of the form:
Billy-1b
Jim-1b
Kelly-1b
The txt
file is called names.dat
and is made up of 160 rows. I want to read the file and create a directory of each entry. Following the above example, I should have in my working directory 3 directories: Billy-1b
Jim-1b
and Kelly-1b
. I am new to bash scripting. Thanks!
Upvotes: 1
Views: 983
Reputation: 15461
You can loop over lines with read
:
while read line; do
mkdir "$line"
done < names.dat
You'll have the same result with :
< names.dat xargs -L 1 mkdir
Upvotes: 2
Reputation: 785058
You can use xargs
with mkdir
like this:
xargs mkdir -p < names.dat
Upvotes: 4