I have a text file that is organized as follows:
Group 1
asdsdsdsdf.html jeff
xcvxcvxcvx.html bob
vrgeiuvhif.html sue
Group 2
iwdowijdoi.html mary
pokpompojm.html doug
ndkjfsjfbs.html lisa
I need a bash script that creates a directory named after each group. And then a text file inside named for each person in that group with their corresponding link on the first line.
I have managed to be able create the directories, the named text files, and a file with only the links. But I don't know how to echo each link into each name file or how to sort them by group.
I'm sure there are better ways to accomplish the small amount that I have.
#!/bin/bash
grep Group list.txt > groups
grep -v Group list.txt > links_names
while read file; do mkdir "${file}"; done < groups
while read line; do export name=`echo $line | awk '{print $2}'`
touch "$name"; done < links_names
while read line; do export link=`echo $line | awk '{print $1}'`
echo "$link" >> links ; done < links_names
rm {groups,links_names,links}