I have bash script looping through several files in a directory. The file identifier has been saved as a variable $num. What I would like to do is add $num as another column in my data like in the example below:
ORIGINAL INPUT:
A B C D E
2 79 56 SD L
1 09 67 JK S
9 60 37 KD G
0 10 47 SO E
EXPECTED OUTPUT:
A B C D E id
2 79 56 SD L 1
1 09 67 JK S 1
9 60 37 KD G 1
0 10 47 SO E 1
*in above example, $num = 1
Ultimately, I want to take a subset of lines from each looped file and cat them into a single large file. For me to know which file the line came from, I need the id from $num.
I have tried using awk '{$12 = $num}' filename but this does not work at all.
Please help!