Newlines

What do the text utilities on AIX have against following the manual and manipulating newlines properly? Is it just that AIX is from IBM, and IBM software is half-assed?

$ uname -a
AIX myhost 3 5 00C2D2804C00
$ echo " 1 2 3 4   5 2 1" | tr -s [:space:] '\n'
 1 2 3 4   5 2 1
$ echo " 1 2 3 4   5 2 1" | tr -s [:space:] '\012'
 1 2 3 4   5 2 1

$ echo " 1 2 3 4   5 2 1" | sed 's/ /\n/g'
n1n2n3n4nnn5n2n1

By properly, I of course mean “How GNU does it.”

$ uname -a
Linux myhost 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686 i686 i386 GNU/Linux
$ echo " 1 2 3 4   5 2 1" | tr -s [:space:] '\n                                                                             '

1
2
3
4
5
2
1

$ echo " 1 2 3 4   5 2 1" | tr -s [:space:] '\012'

1
2
3
4
5
2
1
$ echo " 1 2 3 4   5 2 1" | sed 's/ /\n/g'

1
2
3
4

5
2
1

Turns out that tr(5) was not matching the class [:space:] or the class [:blank:], but would match and transform the single character ' ' (space). Still not sure WTF is up with sed(5). The simple solution to this problem, of course, is to avoid AIX.

Related Posts with Thumbnails
This entry was posted in rant, Work. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>