in reply to awk 2 perl oneliner

I am not an awk expert. But from your problem statement, you have file 1 with some names. Then another file 2 with some data. The output swaps the data associated with >name1 and >name3. Can you show what would happen if there was say, some >name2 or some >name4 data there?

I don't find: "awk 'NR==FNR {a$1;next} $1 in a {print RS$0}' file1 RS=">" file2 > output" easy to understand.

Replies are listed 'Best First'.
Re^2: awk 2 perl oneliner
by zwon (Abbot) on Mar 06, 2010 at 10:53 UTC
    The output swaps the data associated with >name1 and >name3.
    Note, that the output shown in OP is incorrect. Actual output will be:
    >name3 text text text text >name1 some kind of text
    So it doesn't swap anything.
      Right, my mistake. Though the order of output is not important to me in this case.