I cannot find an easy solution for this problem in bash.
I have several files: aaa.txt / bbb.txt / ccc.txt
The content of each file is:
aaa.txt
1234
1234
1234
bbb.txt
5678
5678
5678
ccc.txt
10
20
30
40
I need to add the name of the file to the beginning of each line using a loop.
There are about 300 files and I want to concatenate all of them in one file to do a grep instead of looking file by file, and the reason to add the name of the file is to do that grep. This should be the result:
aaa.txt
aaa: 1234
aaa: 1234
aaa: 1234
bbb.txt
bbb: 5678
bbb: 5678
bbb: 5678
ccc.txt
ccc: 10
ccc: 20
ccc: 30
ccc: 40
Could you help me?
If there is any doubt just ask for it
Thanks!