User Tools

Site Tools


ubuntu:sed:new_line

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ubuntu:sed:new_line [2019/12/04 20:07] – created peterubuntu:sed:new_line [2019/12/10 18:38] (current) – removed peter
Line 1: Line 1:
-====== Ubuntu - SED - New line ====== 
- 
-Neither **\s*** (as I would use in javascript and php) nor **\s\{3,\}** works. 
- 
-Note too that **\n** is not recognized as a new line. To get a new line **\'$'\n** must be used. 
- 
-To modify the .profile file. 
- 
-<code sed> 
-#sed -i .bak  's/^\(export[ ]*JAVA_HOME.*\)/#&\'$'\nexport\ JAVA_HOME=\/Users\/${USER}\/\.java_jdk_6\/soylatte16-i386-1\.0\.3/' ~/.profile 
-#sed -i .bak  's/^\(export[ ]*JAVA_HOME.*\)/&\'$'\nexport\ PATH=${JAVA_HOME}\/bin:$PATH/' ~/.profile   
-</code> 
- 
-The two lines above did what I wanted but the second line did a backup of the modified ~/.profile.  So I came up with the next solution. 
- 
-<code sed> 
-sed -i .bak  's/^\(export[ ]*JAVA_HOME.*\)/#&\ 
-\export\ JAVA_HOME=\/Users\/${USER}\/\.java_jdk_6\/soylatte16-i386-1\.0\.3\ 
-\export\ PATH=${JAVA_HOME}\/bin:$PATH/' ~/.profile 
-</code> 
- 
-The new line is achieved by ending a regex with \ and continuing it with \ on the next line. If there are white spaces in front of \ they will also appear in ~/.profile. 
  
ubuntu/sed/new_line.1575490062.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki