unix - to insert line breaks in a file whenever a comma is encountered-Shell script -
i need write shell script re-format file inserting line breaks. condition line break should inserted when encounter comma in file.
for example, if file delimiter.txt
contains:
this, file, should, added, a, line break, when find, comma.
the output should be:
this file should added line break when find a comma.
can done grep
or awk
?
using gnu sed
:
sed 's/, /\n/g' your.file
output:
this file should added line break when find a comma.
note: syntax above work on system have \n
line delimiter linux , unixes.
if need portal solution in a script use following expression uses literal new line instead of \n
:
sed 's/,[[:space:]]/\ /g' your.file
thanks @edmorten advice.
Comments
Post a Comment