Answers for "bash replace character with new line"

2

bash replace character with new line

# Basic syntax:
:%s/character/r/g # note, use r instead of n

# Example usage:
# Say you have a file with a line this and you want all parameters on different
# lines:
<param_1> <param_2> <param_3> <param_4>

# You could run:
:%s/ /r/g # to get:
<param_1>
<param_2>
<param_3>
<param_4>

# Or you could run something like:
%s/<> </r:/g # to get:
<param_1:
param_2:
param_3:
param_4> # which saves you some work if you also want to delete the separators
Posted by: Guest on February-02-2022

Code answers related to "bash replace character with new line"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language