I have several files in one directory in Linux that look like:
John Smith-data.txt
Peter Walker-address.txt
...
I want a script that reads these filenames and creates one directory for each name in the filename, that is
John Smith
Peter Walker
If I do
for name in `ls | awk -F - '{print $1}'`; do mkdir $name; done
the following directories are created
John
Smith
Peter
Walker
by doing
for name in `ls | awk -F - '{print $1}'`; do mkdir "$name"; done
I get the same result
Then, doing
for name in "`ls | awk -F - '{print $1}'"`; do mkdir "$name"; done
creeates only one dir named:
John Smith Peter Walker
Finaly, if I enter
for name in "`ls | awk -F - '{print $1}'"`; do mkdir $name; done
again I get
John
Smith
Peter
Walker
Any ideas ? How to use the quotes ""
?
Thanks in advance
Xavier