Combine 3 files based on a pattern

HI,

I have 3 files that contain the following information (sql output from Oracle database stored in a txt file):

File1.txt :

alter table "SYS"."INT_COST_PRICE" enable row movement;
alter table "SYS"."INT_SOH" enable row movement;
alter table "SYSMAN"."XX_ACI_SKURTP" enable row movement;

second file contains the following information (source same as above):
File2.txt

alter table "SYS"."INT_COST_PRICE" shrink space compact;
alter table "SYS"."INT_SOH" shrink space compact;
alter table "SYSMAN"."XX_ACI_SKURTP" shrink space compact;

Third file contains the following information (source same as above):
File3.txt

alter table "SYS"."INT_COST_PRICE" disable row movement;
alter table "SYS"."INT_SOH" disable row movement;
alter table "SYSMAN"."XX_ACI_SKURTP" disable row movement;

I would like to combine the files together into one single file and having an output as shown below (with blank lines after every 3 lines:

Final_output_file.txt

alter table "SYS"."INT_COST_PRICE" enable row movement;
alter table "SYS"."INT_COST_PRICE" shrink space compact;
alter table "SYS"."INT_COST_PRICE" disable row movement;

alter table "SYS"."INT_SOH" enable row movement;
alter table "SYS"."INT_SOH" shrink space compact;
alter table "SYS"."INT_SOH" disable row movement;

alter table "SYSMAN"."XX_ACI_SKURTP" enable row movement;
alter table "SYSMAN"."XX_ACI_SKURTP" shrink space compact;
alter table "SYSMAN"."XX_ACI_SKURTP" disable row movement;

Kindly help me out.

Thanks,
Ram.

Try:

paste -d"\n" file{1..3}
alter table "SYS"."INT_COST_PRICE" enable row movement;
alter table "SYS"."INT_COST_PRICE" shrink space compact;
alter table "SYS"."INT_COST_PRICE" disable row movement;
alter table "SYS"."INT_SOH" enable row movement;
alter table "SYS"."INT_SOH" shrink space compact;
alter table "SYS"."INT_SOH" disable row movement;
alter table "SYSMAN"."XX_ACI_SKURTP" enable row movement;
alter table "SYSMAN"."XX_ACI_SKURTP" shrink space compact;
alter table "SYSMAN"."XX_ACI_SKURTP" disable row movement;

To get those empty lines, create a file4 with three empty lines and run paste -d"\n" file{1..4}

2 Likes

Also for blank lines you can use /dev/null (The empty file)

paste -d"\n" file{1..3} /dev/null
1 Like

RudiC,

Thank You very much. It helped a lot.

Thanks,
Ram.

---------- Post updated at 11:53 AM ---------- Previous update was at 11:50 AM ----------

Hello Chubler_XL,

Thank You very much. Even better in a single liner.

Thanks,
Ram.

Sorry --- I didn't notice properly...

Thanks Chubler_Xl

Cool solution what does {1} do?

EDIT: Hang on all the file1 stuff is together, it's supposed to be 1 line from each file.

Sorry I didn't notice properly...