Link to home
Start Free TrialLog in
Avatar of Nandika Kodituwakku
Nandika Kodituwakku

asked on

Unix Shell Scripting to Change the header of the file in Unix

Hi,

I have a situation here:

I have some files:
 update_1.dat, update_2.dat,update_3.dat.....update_x.dat

Each file will have a header as first record in it to determine it's sequence.

Say for ex:

update_1.dat
001|201501300940193201|XXXX02|1|201501303|YYYY30|20|1|1|

update_2.dat
001|201501300940193201|XXXX02|1|201501303|YYYY30|20|1|1|

The above is what I have right now..

I am expecting and what I am trying to achieve is
001|201501300940193201|XXXX02|1|201501303|YYYY30|20|1|2| -- Update_1.dat
001|201501300940193201|XXXX02|1|201501303|YYYY30|20|2|2| -- Update_2.dat and so on

If I have three files ,then  header should be

001|201501300940193201|XXXX02|1|201501303|YYYY30|20|1|3| -- Update_1.dat
001|201501300940193201|XXXX02|1|201501303|YYYY30|20|2|3| -- Update_2.dat and so on
001|201501300940193201|XXXX02|1|201501303|YYYY30|20|3|3| -- Update_2.dat and so on

I want some advices and suggestions to achieve this.

Also, it would be great if I get the sample code piece to achieve the above scenario.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of johnsone
johnsone
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nandika Kodituwakku
Nandika Kodituwakku

ASKER

I've requested that this question be deleted for the following reason:

I want to hide it..I got the solution from the expert..I am happy
If the solution is posted, you should accept the solution.  You cannot delete it, just because.