I want to rename .gz files according to names in separate txt-file. I have a map with .gz files with the names:
trooper10.gz
trooper11.gz
trooper12.gz
etc.
and I have a separate txt-file with the wanted name(s) in in the first column and the .gz-names in the other column (tab-separated).
B25 trooper10
C76 trooper11
A87_2 trooper12
So the files should be renamed like this
B25.gz
C76.gz
A87_2.gz
I tried
for i in *.gz; do
line=$(grep -x -m 1 -- "${i}" /path_to_txtfile/list_names.txt)
But im not sure how to grep the corresponding column in the txt-file. Since there is many gz-files I want to ask if there is any way to this?