Using sed in a for loop

view story

http://www.unix.com – Hello I have a group of files Code: a1.profile a2.profile a3.profile a4.profile b1.profile b2.profile b3.profile b4.profile These files all have the same first line with a value s1 atop the columns Code: s1_context s1_ref s1_sample s1_% etc I am trying to use sed in a for loop to replace the s1 in the header of each each file with the initial part of the filename with something like Code: for FILE in a1 a2 a3 a4 b1 b2 b3 b4 do     sed -i.bak "1s/s1/$FILE/g" $FILE.profile > $FILE.profile.header done But I am not getting the desired output. I just ge (HowTos)