This is a continuation of my previous question Bash: Choose row with the highest value in specified column in multiple files and create one output file with rows containing the max
The solution I used is:
for file in mi*
do
sort -k14,14 -n $file | tail -1
done > result
I am wondering if there is an easy way to edit this code so that when I create the output file I can add a column that contains the file names, or if I need to use a different approach.
I found this question Bash Command Get Data from multiple files and append the file name but I am not sure how to adapt it for my needs
Update with more info: files are tsv and have column names