Need this output

i have a text with the following

ora.epayprd.db
      1                                                              OFFLINE       ONLINE            sec37-7                          Open
      2                                     ONLINE          ONLINE           sec36-8                          Open
ora.scan1.vip
      1                                   ONLINE          OFFLINE         sec36-8

I need the output to be like this only the line which contains offline word

 ora.epayprd.db:OFFLINE :ONLINE:            sec37-7:                          Open
  ora.epayprd.db: ONLINE:ONLINE:sec36-8:Open
  ora.scan1.vip:ONLINE:OFFLINE:         sec36-8

I can't see your desired output to be related to neither input nor requirement phrasing.

ok i updated it please check if you can get the output from this text

Given the 1st three lines of your input:

ora.epayprd.db
1 OFFLINE ONLINE sec37-7 Open
2 ONLINE ONLINE sec36-8 Open

I can see how to get the 1st two lines of your desired output:

ora.epayprd.db:OFFLINE : ONLINE: sec37-7: Open
ora.epayprd.db: OFFLINE: ONLINE: sec36-8: Open

if I ignore that inconsistent spacing before and after the colons. But, given the last two lines of your input:

ora.scan1.vip
1 ONLINE OFFLINE sec36-8

I don't see any way to magically transform that into:

ora.ARCHIVES_DG.dg: OFFLINE: ONLINE: sec36-8

How are we supposed to determine that ora.scan1.vip should be translated to ora.ARCHIVES_DG.dg and that ONLINE OFFLINE should be reordered to be OFFLINE: ONLINE: . If you want us to help you, you need to give us a much better description of the processing involved that makes these transformations.

so sorry i didn't see this word
ora.ARCHIVES_DG.dg

i edited the output again

$ cat file
ora.epayprd.db
1 OFFLINE ONLINE sec37-7 Open
2 ONLINE ONLINE sec36-8 Open
ora.scan1.vip
1 ONLINE OFFLINE sec36-8
$ awk '{if($0 ~ /^ora/){s=$0} else{sub($1,"");gsub(FS,":");print s,$0}}' file
ora.epayprd.db :OFFLINE:ONLINE:sec37-7:Open
ora.epayprd.db :ONLINE:ONLINE:sec36-8:Open
ora.scan1.vip :ONLINE:OFFLINE:sec36-8

could you explain what "else{sub($1,"")" this mean to understand this script what $1 mean ?

thanks alot

sub($1,"") means substitute $1 from $0 . Means remove first column from the line.

this script work fine but i have another sample which changed this script

$ cat file 
ora.epayprd.db 
OFFLINE ONLINE sec37-7 Open 
ONLINE ONLINE sec36-8 Open 
ora.scan1.vip 
ONLINE OFFLINE sec36-8 

without the numbers of the each line

want the output like this

ora.epayprd.db :OFFLINE:ONLINE:sec37-7:Open 
ora.epayprd.db :ONLINE:ONLINE:sec36-8:Open 
ora.scan1.vip :ONLINE:OFFLINE:sec36-8

this is very small change to my script.(removed sub($1,"") ) part :slight_smile:

$ cat file
ora.epayprd.db
OFFLINE ONLINE sec37-7 Open
ONLINE ONLINE sec36-8 Open
ora.scan1.vip
ONLINE OFFLINE sec36-8
awk '{if($0 ~ /^ora/){s=$0} else{gsub(FS,":");print s":"$0}}' file
ora.epayprd.db :OFFLINE:ONLINE:sec37-7:Open
ora.epayprd.db :ONLINE:ONLINE:sec36-8:Open
ora.scan1.vip :ONLINE:OFFLINE:sec36-8

ok thanks this is very perfect i tried it on linux system and work but i tried it on solaris gave me this

-bash-3.00$ awk '{if($0 ~ /^ora/){s=$0} else{sub($1,"");gsub(FS,":");print s,$0}}' cl2
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: illegal statement near line 1

i tried this it work so i don't know how to write more than function inside else ?
-bash-3.00$ awk '{if($0 ~ /^ora/){s=$0} else{print s,$0}}' cl2

---------- Post updated at 06:42 AM ---------- Previous update was at 06:35 AM ----------

i found the problem of the binary file of awk in solaris i must use this to support all functions
/usr/xpg4/bin/awk