I would like to add:function ps_mem {   python /home/vagrant/ps_mem/ps_mem.py -p $@}To the end of ~/.bashrc from the command-line. I have tried using:printf function ps_mem {\n python /home/vagrant/ps_mem/ps_mem.py -p $@ \n} >> ~/.bashrcAnd while it almost worked, the input field $@ was ignored, making this:function ps_mem { python /home/vagrant/ps_mem/ps_mem.py -p}Instead, be added to the end of ~/.bashrc. 
How do I append multiple lines involving variables to the end of a bash script?
shell script;bashrc;printf
Other answers have been given which will work, but in the spirit of helping you do it exactly the way you were trying to (since it's a totally fine way to do it):Here is the original:printf function ps_mem {\n python /home/vagrant/ps_mem/ps_mem.py -p $@ \n} >> ~/.bashrcHere is a version that works:printf 'function ps_mem {\n python /home/vagrant/ps_mem/ps_mem.py -p $@ \n}' >> ~/.bashrcI recommend adding double quotes around $@ also:printf 'function ps_mem {\n python /home/vagrant/ps_mem/ps_mem.py -p $@ \n}' >> ~/.bashrcVariable expansion is enabled in double quotes; disabled in single quotes.