Sample Header Ad - 728x90

How does unexpand command really work?

4 votes
1 answer
744 views
I've already read some explananations about unexpand, but either I don't understand, or is not working as expected. Let's consider the following example: [root@hope log]# echo "A12345678B" | tr '[1-8]' ' ' | unexpand -a A B [root@hope log]# echo "A12345678B" | tr '[1-8]' ' ' | unexpand -a | od -ta 0000000 A ht sp B nl 0000005 [root@hope log]# echo "A12345678B12345678C" | tr '[1-8]' ' ' | unexpand -a | od -ta 0000000 A ht sp B ht sp sp C nl 0000011 [root@hope log]# echo "12345678" | tr '[1-8]' ' ' | unexpand -a | od -ta 0000000 ht nl 0000002 I see that it replaces 8 blanks with one tab, but it appends one more space each time it appears some non-blank character. Using bash-4.3.42-3.fc23.x86_64 and coreutils-8.24-6.fc23.x86_64 Please could you explain this behaviour?
Asked by sebelk (4669 rep)
Mar 14, 2016, 09:53 PM
Last activity: Mar 14, 2016, 10:51 PM