I'm not at all sure that I understand what you're trying to do.
You say you want to print Home=1 (if it is Alive ) or Home=2 (if it is down , but down with a lowercase d does not appear anywhere in your input), but instead of printing DSA=2 , you printed nothing??? You say the first line of the output should be Home=1 , but Home (with an uppercase H ) does not appear anywhere in your input data???
Please give a clearer description of what output you hope to produce from this output. Please tell us what form this output takes. (Is it a string in a shell variable? Is it being written to a pipe by some other process? Is it stored in a file?) Please tell us what you want to do with the transformed output.
Thank you dear RudiC.
would you lease explain little bit your code?
the output has a little problem but it worked.
i want to try split the command and fix the problem. i use this one but it didnt work:
Looks like your output variable contains more lines than your sample in post #1. The first three items seem to reflect the header of your status which should be excluded by NR>3.
awk -F\| # run awk with "|" as the field separator
' # start of first parameter (program text)
NR>3 # pattern 1: skip lines 1 - 3 incl., TRUE above 3. line
{ # open the action 1
gsub (/ /,_); # replace spaces with nothing (_ is an undefined thus empty variable)
print $2 "=" ($4=="Alive") # print 2. field, "=", and the logical value (0/1) of the comparison
} # close action 1
' # close first parameter