I am a beginner at Linux and I'm trying to do a project which takes every line from a file.txt and replaces the third word with the first of each line. Here is my Shell code but it doesn't seem to work. It keeps replacing the third word with $field1 and not what's in it.
#!/bin/bash
while IFS=: read -r field1;do    
    sed -e 's/[^:]*[^:]/$field1/3'
done < file.txt
 
     
     
     
    