You are not logged in.
Pages: 1
can anyone show me how to create directories from a text file.
each line = 1 folder
name
name lastname
and so on...
thanks in advance
Offline
For ones without spaces you can use
mkdir -p $(cat file)
edit 1: if the paths aren't absolute it will be better to cd into the directory you want to create them in
Last edited by SS4 (2011-01-28 16:37:59)
Rauchen verboten
Offline
#!/bin/bash
IFS='
'
for _dir in $(cat "$1"); do
mkdir "$_dir"
done
Invoke it with the path to the text file.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Thanks a lot that was fast.
i was trying to get this command to work but it kept putting ? and spaces at the end of the name
while read line; do mkdir -v "$line"; done < test.txt
how would i fix that?
Offline
#!/bin/bash IFS=' ' for _dir in $(cat "$1"); do mkdir "$_dir" done
Invoke it with the path to the text file.
I tried that but it still put "?" at the end of the name
some of the names have up to 30 characters in length
Offline
Both that, and your "read" loop work for me. Maybe there's something wrong with the encoding of your file.
Can you post the test.txt file that you're using so that I can test it?
Last edited by Xyne (2011-01-28 16:56:54)
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Perhaps your input file has msdos style line terminators ie \r\n
Offline
Perhaps your input file has msdos style line terminators ie \r\n
That's what I'm thinking.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
skunktrader wrote:Perhaps your input file has msdos style line terminators ie \r\n
That's what I'm thinking.
well it was created in notepad and the list was copied from a Excel sheet, how would i go about removing that?
Offline
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Thanks
Offline
One more question, I got the folders created now, but when i access it from a windows computer through the network the name of the folder goes from
Name Of Company 1
to
NFSDGF2~1
but on Linux it doesn't.
im using samba shares
Offline
Pages: 1