Issue
I have two subdirectories named "Sample" and "Price". "Sample" consists one file named "1.tsv" while "Price" consists of >10000 tsv files named A.tsv, B.tsv ....and so on. I want to insert the 1.tsv into every file present in the "Price" directory before the first column.
Sample file in "Sample" folder: 1.tsv
Name | ID |
---|---|
Samul | 25 |
Alex | 36 |
RDXC | 14 |
Plut | 38 |
Sample file in "Price" folder: A.tsv
Name | ID |
---|---|
Rajn | 39 |
Maxo | 05 |
DNDT | 11 |
Maxi | 21 |
Sample file in "Price" folder: B.tsv
Name | ID |
---|---|
Cars | 98 |
Lint | 20 |
Marq | 45 |
DNSA | 17 |
and then c.tsv, d.tsv......etc
Output file: 1.tsv and A.tsv
Name | ID | Name | ID |
---|---|---|---|
Samul | 25 | Rajn | 39 |
Alex | 36 | Maxo | 05 |
RDXC | 14 | DNDT | 11 |
Plut | 38 | Maxi | 21 |
Output file: 1.tsv and B.tsv
Name | ID | Name | ID |
---|---|---|---|
Samul | 25 | Cars | 98 |
Alex | 36 | Lint | 20 |
RDXC | 14 | Marq | 45 |
Plut | 38 | DNSA | 17 |
and same with other files like 1.tsv and c.tsv, 1.tsv and d.tsv.......so on. This is sample data, in reality, each file has around 56000 raws. Thank you in advance.
Solution
$ for f in Sample/*.tsv; do paste -d'\t' Price/1.tsv "$f" > "$f".updated; done
Answered By - karakfa Answer Checked By - Timothy Miller (WPSolving Admin)