I want to create a script (script.sh) to change the contents of /etc/proxychains.conf. I would like to do it in the form of a menu though, so something like this:After runing ./script.sh[1] Add Proxychain[2] Start Proxychains[3] ExitPlease select an option:If the user selects [1] I would like to to ask for these inputs:Type of Proxy:Proxy IP Address:Proxy Port:And use these inputs in this form: (socks5  127.0.0.1 9050) at the bottom of the file /etc/proxychains.conf where you would normally add your proxy info. I was thinking of maybe assigning each input like $type  $ip $port (so you can display each field next to each other). But how can I make it so it automatically finds that spot in the file proxychains.conf and adds those fields to it under any other ones priviously added. And After I would like to return back to the option menu where if the user presses [2] then it would run:proxychains firefoxAnd of course after firefox closes I would like to bring back the menu where if the user selects [3] the it would echo Goodbye sleep 1s and exit.
(Shell Scripting) - Modify files with user input
bash;shell script;terminal
This script should have solved your problem.And Next Time try to write a script and ask if you have any problem instead of asking for whole solutions.#! /bin/bashfunction menu {    echo     echo ++++++++++++++++++++++++++++++++++++++++++++    echo +++++proxychain applications version1.0+++++    echo ++++++++++++++++++++++++++++++++++++++++++++    echo [1] Add Proxychain    echo [2] Start Proxychains     echo [3] Exit    echo [4] Cat specified file    read -p Please select an option :  option}function input {    read -p Input Type of Proxy :  type        read -p Input Proxy IP Address :  ip_addr        read -p Inport Proxy Port :  port        if [ ! -z ${type} ]&&[ ! -z ${ip_addr} ]&&[ ! -z ${port} ]    then        echo -e ${type}\t${ip_addr}\t${port} >>proxychains.conf    else        input       fi}function start {    echo proxychains firefox}function terminate {    if [ -z $(pgrep firefox) ]    then        echo -e Goodbye\n        sleep 1        end_script=1        exit 0    else        echo -e Terminating firefox!\n        pkill firefox        echo Goodbye        end_script=1        exit 0    fi}function catme {    read -p Input the file path :  file_path    cat ${file_path}    exit 0}end_script=0while [ ${end_script} != 1 ];do    menu    current_stage=${option}    case ${option} in        1)            input        ;;        2)             start        ;;        3)             terminate            exit 0        ;;        4)              catme        ;;        *)            echo unknown usage!        ;;    esac