vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I have 3 flat files, have to merge those files into one file and have to append the individual sequence number from the filename to its file individual file data File Names: ============== xxx.000123.dat xxx.000124.dat xxx.000125.dat .. .. .. For example if File name 1: "xxx.000123.dat" has all the last names of 10 people and file name 2:"xxx.000124.dat" has 10 Last Name, I have merge them into a one file XXX.dat with 20 records and and at the same time have the add the number from the file "000123" at the beginning all the 10 records and add the number from the file "000124" at the beginning of the other 10 records in the merged file. |
| |||
| vp wrote: > I have 3 flat files, have to merge those files into one file and have > to append the individual sequence number from the filename to its file > individual file data > > File Names: > ============== > xxx.000123.dat > xxx.000124.dat > xxx.000125.dat > .. > .. > .. > > > For example if File name 1: "xxx.000123.dat" has all the last names of > 10 people and file name 2:"xxx.000124.dat" has 10 Last Name, I have > merge them into a one file XXX.dat with 20 records and and at the same > time have the add the number from the file "000123" at the beginning > all the 10 records and add the number from the file "000124" at the > beginning of the other 10 records in the merged file. > perl -ne '$ARGV =~ /\.(\d+)\.dat/; print "$1 $_"' xxx.*.dat > xxx.dat -- Alex. |
| ||||
| On Feb 15, 11:44 am, "vp" <vijay_...@yahoo.com> wrote: > I have 3 flat files, have to merge those files into one file and have > to append the individual sequence number from the filename to its file > individual file data > > File Names: > ============== > xxx.000123.dat > xxx.000124.dat > xxx.000125.dat > . > . > . > > For example if File name 1: "xxx.000123.dat" has all the last names of > 10 people and file name 2:"xxx.000124.dat" has 10 Last Name, I have > merge them into a one file XXX.dat with 20 records and and at the same > time have the add the number from the file "000123" at the beginning > all the 10 records and add the number from the file "000124" at the > beginning of the other 10 records in the merged file. Better use a join command to merge common fileds in a file( use loops to join a number of files, if the files are less these can be directly specified). Use awk to add the desired fileds. HTH |
| Thread Tools | |
| Display Modes | |
|
|