I have an array of list and a file file1.txt , I want to create e new file order according to numbers in file1.txt, for example code output must be like below. How should I make it work correctly
newfile.txt 9 Z A C
but script gives me newfile.txt 2 3 4 9
file1.txt's content is like below random numbers 2 3 4 1
list=("Z" "A" "C" 9)
while read line
do
for i in ${list[@]};do
sed "${line}s/.*/${i}/" file1.txt > newmfile.txt
done
done < "file1.txt"
A C 9 Zfor2 3 4 1? LikeAis the second element,Cis the third,9is the fourth, andZis the first.