Store the last 10 strings. A way to make it elegant?

Hello,

Please find an ugly code. bouuu.
It shall work onto RAM only to update from the last 10 strings from $URLTO. I shall read first : "$HOME/.fvwmoscfg/fvwmclipboardmplayerplayurl10.ini"

The code works but it is very ugly. How could it be made elegant please?

Thank you

            THETENLASTILES=`cat "$HOME/.fvwmoscfg/fvwmclipboardmplayerplayurl10.ini"`
            echo "${URLTO}" > "$HOME/.fvwmoscfg/fvwmclipboardmplayerplayurl10.ini"
            echo "$THETENLASTILES" >>  "$HOME/.fvwmoscfg/fvwmclipboardmplayerplayurl10.ini"
            THETENLASTILES=`cat "$HOME/.fvwmoscfg/fvwmclipboardmplayerplayurl10.ini" | head -n 10`
            echo "$THETENLASTILES" >  "$HOME/.fvwmoscfg/fvwmclipboardmplayerplayurl10.ini"

I suppose you want the latest 10 lines

#!/bin/bash
file="$HOME/.fvwmoscfg/fvwmclipboardmplayerplayurl10.ini"
URLTO="add this on top"
sed -i "1 i $URLTO" $file
TOPTENLINES=$(sed -n '1,10 p' $file)
echo -e "$TOPTENLINES"

--ahamed

Close, try

sed -i -e "1i$URLTO" -e '$d' $file