0
I have a e-book directory that has following format:
<authorname> <authorsurname> - <bookname>
I want to separate the books by authors. I use the below command in a for-loop for this operation:
for author in $(ls /home/me/books | awk -F "-" '{print $1}' | sort | uniq)
do
make a directory and push all books of this author to this directory
done
I expect to see authorsurname value on next of authorname value but these values getting printed line by line. If I run the ls command that in the for-loop as individual this time it runs as I want (output 1). But in a loop, it doesn't (output 2).
Visually Output:
What I want:
Edgar Allan Poe
Marcus Aurelius
What happens:
Edgar
Allan
Poe
Marcus
Aurelius
How can I fix this issue and sort the authors as name and surname in same line?
Edit: I tried "cat" a file that contains author names. But it didn't work too.
Why not parse
ls
? – Cyrus – 2019-07-13T17:32:11.680