Help need on cat command

I have two files as below

1.txt

AA 123
CC 145
DD 567

2.txt

AA 111
YY 128
CC 144
FF 222
DD 777
ZZ 875

basically 1.txt is updated file, if i do cat 1.txt 2.txt output should be as below
o/p

 
AA 123
YY 128
CC 145
FF 222
DD 567
ZZ 875

basically 1.txt should override on 2.txt
Please share inputs if some one knows..

cat is an existing command with a specific meaning, different to that you require.

try something like the following instead

 perl -ne '$entry{$1}=$2 if /^([^\s]+)\s([^\s]+)$/; END{for (sort keys %entry){print "$_ $entry{$_}\n";}}' tmp/2.txt tmp/1.txt
AA 123
CC 145
DD 567
FF 222
YY 128
ZZ 875

A few points to note, the records will be printed sorted on the first field.
The latest file should be provided last (the command will deal with more than 2 files)

try also:

awk 'NR==FNR {a[$1]=$0; next} a[$1] {$0=a[$1]} 1' 1.txt 2.txt

awk 'NR==FNR {a[$1]=$0; next} a[$1] {$0=a[$1]} 1' 1.txt 2.txt
awk: syntax error near line 1
awk: bailing out near line 1

any idea..

Use nawk on solaris.