Showing posts with label awk. Show all posts
Showing posts with label awk. Show all posts

Thursday, September 29, 2011

Replacing 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
3 ways to do it, have fun