Can i do the following in the terminal? (written in pseudo-code)
for (int i=1;i<=5;i++) {
replace first line of fileout.text by i-th line of filein.txt
}
i guess it somehow involves using sed, but i don't know how to sed from one file to another.
EDIT: I frame Htorque's answer inside a loop:
for (( i = 1 ; i <= 10 ; i++ )); do
line=$(sed -n "${i}p" filein.txt)
sed -i "1c\\$line" fileout.txt
done
which works like a charm. It is possible to replace the fixed string '10' in the counter by the actual number of lines of filein.txt:
nline=$(sed -n '$=' filein.txt)
for (( i = 1 ; i <= $nline ; i++ )); do
line=$(sed -n "${i}p" filein.txt)
sed -i "1c\\$line" fileout.txt
done