I'm trying to write a command to capture every license in the linux OS (kali) and associate it with the correct package. The basic idea is that you search /usr/share/doc recursively for "copyright" file, then you cat that and search for "^License" the leading license. There can be multiple per package.
I'm trying to create a csv that takes all of the package names and puts them in the first field of each row, and then follows it with each license comma delimited.
My basic flow: make a list of every package (done). Make a list where each line is csv of the licenses found. Then just paste file 1 and file 2, boom.
Problem, I have to swap the newlines in the output of the command with comma's, but I need to then re-insert a newline at the end for each iteration of xargs so my csv licenses will line up with the package list. I've tried this dozens of ways. When I do command substitution it breaks translate or echo (doesn't read \n as a newline anymore. I've tried \\n, no luck).
Here is what I have that just needs a way to put a newline per xargs cycle.
find . -name copyright |xargs -l cat |grep "^License" |tr '\n' ','
So if I could just pipe to something that inserts \n after every xarg cycle I'd be done. I know I can write a for loop for this with variables.