Created
January 14, 2021 19:22
-
-
Save andmax/44c6dbb1603a7ccccde467268ddfe120 to your computer and use it in GitHub Desktop.
Replace the last character of the last line of a file with sed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. The problem is to add a new entry to the PATH | |
2. environment variable for all users system wide | |
3. for both logged-in (interactive) and non-logged-in | |
4. (non-interactive) shells using the /etc/environment | |
5. (the /etc/profile.d scripts are only applied to logged-in shells) | |
6. which is not a bash script rather a list of one variable set | |
7. (without appending) per line and I want to replace the already | |
8. existing PATH in the last line (there is only one line) | |
9. by removing the last character (a double quote) with a | |
10. colon (:) and then appending the new entry to PATH | |
11. that is OpenMPI binaries path: | |
su - | |
echo $(sed '$ s/.$/:/' /etc/environment)/usr/local/openmpi/bin/\" >> /etc/environment |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment