The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 -->
  #3 (permalink)  
Old 05-27-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
Quote:
Originally Posted by mohan705 View Post
Hi
I have flat file with 100 records ,I need to fabricate data into flat file .

ex:
Code:
file.txt

102345  1000 200  300
...............................
..............................
102346  2000 300  4000


In above file the 4th row, 1 st column valu to be increment by 1 
and rest of the values are same for 1000 lines. 

102347  2000 300  4000

102348  2000 300  4000

Code:
awk 'NR == 4 { $1 = $1 + 1 } { print }' file.txt
If you want more lines than the 4th incremented, change NR == 4. For example, to get the 4th to the end of the file, change it to NR >= 4.