Find the answer to your Linux question:
Results 1 to 6 of 6
hi i ve a file list.txt in this manner 0.5303nS 2.0830V 2.0080V 2.2090V 0.5556nS 2.0830V 2.0070V 2.2120V 0.5808nS 2.0830V 2.0070V 2.2150V 0.6061nS 2.0840V 2.0070V 2.2200V 0.6313nS 2.0850V 2.0070V 2.2260V 0.6566nS ...
  1. #1
    Just Joined!
    Join Date
    Jan 2009
    Posts
    12

    script for equal spacing.

    hi i ve a file list.txt in this manner

    0.5303nS 2.0830V 2.0080V 2.2090V
    0.5556nS 2.0830V 2.0070V 2.2120V
    0.5808nS 2.0830V 2.0070V 2.2150V
    0.6061nS 2.0840V 2.0070V 2.2200V
    0.6313nS 2.0850V 2.0070V 2.2260V
    0.6566nS 2.0870V 2.0060V 2.2340V
    0.6818nS 2.0900V 2.0060V 2.2440V

    i need to align the values in the list with equal spacing without any tab characters.
    expected output:

    0.5303nS 2.0830V 2.0080V 2.2090V
    0.5556nS 2.0830V 2.0070V 2.2120V
    0.5808nS 2.0830V 2.0070V 2.2150V
    0.6061nS 2.0840V 2.0070V 2.2200V
    0.6313nS 2.0850V 2.0070V 2.2260V
    0.6566nS 2.0870V 2.0060V 2.2340V
    0.6818nS 2.0900V 2.0060V 2.2440V
    Last edited by rajeshhariharan22; 01-07-2009 at 10:54 AM. Reason: unequal spacing in the text

  2. #2
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    Try this:

    Code:
    awk '$1=$1' list.txt > newfile
    Regards

  3. #3
    Just Joined!
    Join Date
    Jan 2009
    Posts
    12

    thnx

    hey thanks a lot

    but if my file consists of a few text before the numeric values ,how will allign only my numeric values without changing the text allignment

  4. #4
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    Post an example of the input file and the desired output. Use code tags to keep the format (alignment).

  5. #5
    Just Joined!
    Join Date
    Jan 2009
    Posts
    1
    Because your before and after are the same I am not entirely sure of what you are after. I think what you are probably looking for is the column utility, 'man column' . If you want to achive equal spacing through scripting I made a post about it here: Kyle Brandt: Bash: Getting Command Line Columns to Line up

    Hope this helps,
    Kyle

  6. #6
    Linux User
    Join Date
    Jun 2007
    Posts
    318
    Quote Originally Posted by kbrandt View Post
    Because your before and after are the same I am not entirely sure of what you are after.
    The before and after probably wasn't the same. The forum software removes extra whitespace.

    This line has triple spaces between words

    Code:
    This   line   has   triple   spaces   between   words

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...