User Tools

Site Tools


sed:convert:convert_space_to_newline:convert_space_to_newline

SED - Convert - Convert space with newline

There are a few ways to achieve that:

1. sed

echo "one two three" | sed 's/ /\n/g'
 
one
two
three

2. awk

echo "one two three" | awk '$1=$1' RS= OFS="\n"
 
one
two
three

3. tr

$ echo "one two three" | tr -s ' ' '\n'
 
one
two
three
sed/convert/convert_space_to_newline/convert_space_to_newline.txt · Last modified: 2020/08/16 11:31 by 192.168.1.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki