Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
98
rated 0 times [  98] [ 0]  / answers: 1 / hits: 135211  / 3 Years ago, sat, august 7, 2021, 12:07:16

I need to add the following lines to the end of .bashrc file in Ubuntu. How can I add these lines automatically using a script. If I run the script, then it automatically inserts the lines at the end of .bashrc file.



export APP="/opt/tinyos-2.x/apps"
export TOS="/opt/tinyos-2.x/tos"

More From » scripts

 Answers
6

Use the echo command to append lines to the .bashrc script



So in your script use these lines



echo 'export APP=/opt/tinyos-2.x/apps' >> ~/.bashrc 

echo 'export TOS=/opt/tinyos-2.x/tos' >> ~/.bashrc


Make sure to use >> (append), if you use a single > you will overwrite the file.



~/.bashrc indicates .bashrc is in your home directory


[#34486] Sunday, August 8, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
algicuade

Total Points: 317
Total Questions: 89
Total Answers: 106

Location: Saint Pierre and Miquelon
Member since Fri, Jan 28, 2022
2 Years ago
;