How can I create a specific line in another file using bash please? Like
echo "Please input the days you want to keep "
$key= ?
touch .beebrc; keep="$key"
where the file ".beebrc" has a line 'keep= x' and "$key" is created in the main script.
But how do I define "$key" please? And write it into ".beebrc" as a new line at position/line 8? The full function is -
function trim {
    echo;
    read -t "$temi" -n1 -p ""$bldgrn" Do you want to delete some of your download history? [y/n/q/r]          $(tput sgr0)" ynqr ;
    case "$ynqr" in
        [Yy]) echo
          read -t "$temi" -n3 -p ""$bldgrn" Please input the days you want to keep $(tput sgr0)" key  ## ask
if test -e .beebrc && grep -q "^keep=" .beebrc 2>/dev/null ; then
sed -i "s/^keep=.*/keep=$key/" .beebrc
 else
echo "keep=$key" >> .beebrc
 #fi
          cd /home/$USER/.get_iplayer
          eval "$player" --trim-history "$key"; cd; ques;
          #echo;;
    [Nn]) ques;;
        [Qq]) endex;;
        [Rr]) exec "$beeb";;
    * ) echo ""$bldgrn" Thank you $(tput sgr0)";;
    esac
     fi
 };
Does this help in defining it all? (Sorry, should've put it in at first)
 
     
     
    