Hello everyone!

Below is a sample flat file (sampleflatfile.dat) i have on UNIX:

AMPS,2324,Subscriber,Unknown,SingleDay,20070413,20070413,

ALPEnt,4516,AllMember,Unknown,DateRange,20070411,20070419,

AGLT,2156,Summary,Unknown,

DUPP,2536,Yes,Unknown,

each line above represents a report to be generated...therefore, the content of the sample flat file above means we need 4 reports (because there are 4 line)...

the file above will go through a loop (line by line) and after a report is processed i want it to say "ReportGenerated" at the end of line... therefore, after 2 reports (from example above) have generated, this is what the file should look like:

AMPS,2324,Subscriber,Unknown,SingleDay,20070413,20070413,ReportGenerated,
ALPEnt,4516,AllMember,Unknown,DateRange,20070411,20070419,ReportGenerated,
AGLT,2156,Summary,Unknown,
DUPP,2536,Yes,Unknown,

can anyone let me know how we can accomplish this? is editing a line in UNIX possible at all? Please provide a sample script for a file: sampleflatfile.dat

thanks again gurus!

Open the file in vim.

press : and type

%s/\n/ReportGenerated,\0\1\2/g

Then hit return and voila.

awk '/^$/{next}     
     { $1=$1"Reportgenerate";print } ' "file"

Hi,

This script will append ReportGenerate to all lines, not first 2 lines.

Hi,

I got the exact script for this..
:1,2 s/\n/testing...\r/

It produces o/p as
1 MPS,2324,Subscriber,Unknown,SingleDay,20070413,testing... 2 ALPEnt,4516,AllMember,Unknown,DateRange,20070411,testing...
3 AGLT,2156,Summary,Unknown,DUPP,2536,Yes,Unknown,
4 DUPP,2536,Yes,Unknown,
5 DUPP,2536,Yes,Unknown,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.