task

Hi all,
I'm newbie and stuck here. Thanks for any help.
Input(txt file)

a b X 
c d Y
e f Z
g h W

Requested output:

a b X Y
c d Y X
e f Z W
g h W Z

Would you care to elaborate on the "rules" on this 'game' (without us having to guess)?

Just a guess:

nawk '!FNR%2 {print prev,$NF;print $0,l;next} {prev=$0;l=$NF}' inputFile

The rule might be:
Reverse the order of column 3 in a circular array, then rotate two notches forward.
Just a guess.

Would help to know what programming language should be used and whether there is a better definition of the rule.

Thanks for comments,
sorry for not giving any description,
rule is quite simple:
take value from last column in every odd row and add it as last column in next row,
similarly take value from last column (original without previous adding) in every even row and add to the end of previous row. etc.
I need kshell script.
Thanks

Did the posted 'guess' serve the purpose?

Unfortunately not, its giving empty result :frowning:

strange, I'm getting the expected output given your sample input file...

Thanks again,
It can happen that X,Y,Z is no the last column but lets say the 2nd, 3rd last, its custom.
But these values are always under the same column.

Thanks

variable 'xyz' denotes the column you want to take into account:

nawk -v xyz=3 '!FNR%2 {print prev,$xyz;print $0,l;next} {prev=$0;l=$xyz}' inputFile

Hi,

First thanks for all your replies.
Sorry I made mistake when explaining
This is how my file looks like:
INPUT:

c1  c2  c3   c4  c5   c6     c7 etc.
 *   *    X     *    *    X1     *
 *   *    Y     *    *    Y1     *
 *   *    Z     *    *     Z1     *
 *   *    W   *    *    W1    *

etc.

(the column position of tho values- X,X1 can be custom) c1-c7 is column number
Values X1-W1 should be replaced with values X-W.

This is what I need:
OUTPUT:

c1  c2  c3   c4  c5   c6    c7 etc.
 *   *    X     *    *    Y       *
 *   *    Y     *    *    X       *
 *   *    Z     *    *    W       *
 *   *    W   *    *    Z        *

etc.
BTW I use RH5 Linux , I dont have nawk ,just awk.
Thanks a lot.

Thanks