I wrote the following bash script to write the proxy in the apt.conf file, and hide it from being echoed to the terminal.
sudo echo "Acquire::http::proxy "http://"$prox":"$port"/";" | sudo tee -a /etc/apt/apt.conf > /dev/null 2>&1
sudo echo "Acquire::https::proxy "https://"$prox":"$port"/";" | sudo tee -a /etc/apt/apt.conf > /dev/null 2>&1
sudo echo "Acquire::ftp::proxy "ftp://"$prox":"$port"/";" | sudo tee -a /etc/apt/apt.conf > /dev/null 2>&1
Although the commands write to the apt.conf file, but on running the script, I get the following error :
E: Syntax error /etc/apt/apt.conf:6: Extra junk at end of file
Help appreciated over this!