Add lines of a list as prefixes in filenames
How about
mapfile -t list < list.txt
i=0
for f in *.gf; do
echo mv "$f" "${list[i++]}_$f"
done
Remove the echo
once you are happy that it is doing the right thing.
With POSIX sh
syntax:
#! /bin/sh -
for f in *.gf; do
IFS= read -r line <&3 || break
mv -i -- "$f" "${line}_$f"
done 3< list.txt
Globbing (here *.gf
) sorts the list of files lexically (as per the locale's collation order in modern and POSIX compliant shells).