The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 11-14-2005
azekry azekry is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 2
add increment field when first field changes

Hi
I have a file that looks like the following:

Name1 aaa bbbb
Name1 ffd hhghg
Name1 dffg ghhhh
Name2 rtrt dfff
Name2 rrtfr tgtt
Name2 dsddf gfggf
Name2 ffffg gfgf
NAme3 fdff ghhgh

Is it possible to format it so that a number increment field is added whenever the first field in a record changes. like that

1 Name1 aaa bbbb
1 Name1 ffd hhghg
1 Name1 dffg ghhhh
2 Name2 rtrt dfff
2 Name2 rrtfr tgtt
2 Name2 dsddf gfggf
2 Name2 ffffg gfgf

Thanks