I have a table and I want to add a column containing, for each line, the name of the file itself. I will post an example below: This is the input:
SPATA17 1 217947738 LYPLAL1 1 219383905 FAM47E 4 77192838 SHROOM3 4 77660162 SHROOM3 4 77660731 SHROOM3 4 77662248
And this the output:
SPATA17 1 217947738 file1 LYPLAL1 1 219383905 file1 FAM47E 4 77192838 file1 SHROOM3 4 77660162 file1 SHROOM3 4 77660731 file1 SHROOM3 4 77662248 file1
I applied the very useful solution you have proposed in this forum (the solution is the one using sed function:
for f in file1 file2 file3; do sed -i "s/$/\t$f/" $f; done) but I have some troubles. The output is not as expected. This is how I visualize it with Vim
SPATA17 1 217947738^M file1 LYPLAL1 1 219383905^M file1 FAM47E 4 77192838^M file1 SHROOM3 4 77660162^M file1 SHROOM3 4 77660731^M file1 SHROOM3 4 77662248^M file1
Is this possibly an error because new line (\n) needs to be removed before? I found the solution not working for me.