[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: about the unix command expand/unexpand

From: Bob Proulx
Subject: Re: about the unix command expand/unexpand
Date: Tue, 16 Jan 2001 13:59:50 -0700


> During the process of my project, I found something strange related to the 
> unix command expand/unexpand. when I expand a text file and then unexpand 
> the just expanded file, the unexpand result is not the same as the exact 
> original text file. I wonder if the expand/unexpand command are 
> intentionally design to have such attribution, 'cauz with my self-developed 
> expand/unexpand command, the file remain the same after first expanded and 
> then unexpanded.

The expand/unexpand commands are not quite opposities of each other.
Some files could be the same.  But other files could be different.
That is okay.  Both commands do what they are defined to do.

Check out the online specification for more details.


In your case a space was not converted back to a tab.  But if there
were two spaces there then it would have been.  Delete one of the
leading 'a's from your test case and try it again.  This is the normal
behavior of unexpand.

But even if unexpand were agressive and converted single spaces to
tabs there are cases where they would not be exact opposites.  Trivial
cases can be shown such as the following:

  $ cat -v -t test.txt
  aaaaa   bbb
  $ expand -8 test.txt > temp1.txt
  $ cat -v -t temp1.txt
  aaaaa   bbb
  $ unexpand -8 -a temp1.txt > temp2.txt
  $ cat -v -t temp2.txt

In this case it is not possible to know how many spaces where there in
the first place.  Or even if any tabs existed at all?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]