Я рекурсивно выбрал строку в каталоге, используя
grep -rwnoH "string" /root/Documents/ | cut -d ":" -f1,2 > input.txt
Это дало мне следующий вывод:
Файл input.txt с содержимым, подобным
/root/Documents/file1.txt:23
/root/Documents/file1.txt:35
/root/Documents/file1.txt:56
/root/Documents/file2.txt:12
/root/Documents/file2.txt:67
/root/Documents/file2.txt:78
/root/Documents/file3.txt:2
/root/Documents/file3.txt:10
Я хочу что-то вроде этого:
/home/root/Documents/file1.txt:23,35,56
/home/root/Documents/file2.txt:12,67,78
/home/root/Documents/file3.txt:2,10