sed or awk help - line numbering w/ different start value

I'm pretty new to sed and awk, and I can't quite figure this one out. I've been trying with sed, as I'm more comfortable with it for the time being, but any tool that fits the bill will be fine.

I have a few files, whose contents appear more or less like so:

1|True|12094856|12094856|Test|
2|True|12209485|12209485|Production|
3|True|13056733|13056773|Test|

The problem is they all start at 1, and I'd like to merge them, starting where the last one left off. For example, the first file has 56 entries, so when I merge another one with it, i'd like it to start at 57 instead of 1. Any ideas?

Please post a relevant sample of your input data and an example of the desired output.

concat the files together, and replace the first field with a counter in awk, something like:

#!/usr/bin/ksh
for file in file1.txt file2.txt file3.txt;do
cat $file >> file.new
done

awk -F\| '
BEGIN {
OFS="|"
}
{
$1=NR
print
}
' file.new

@radoulov I have a master file, master.txt, with about 50 lines like the following:

1|True|12094856|12094856|Test|
2|True|12209485|12209485|Production|
3|True|13056733|13056773|Test|
...
56|True|38077408|38077408|Production
I also have 3 other, shorter files that I want appended to the master file, continuing the count in the first column where it ends in the master page, so tmpFile1 has this content:

1|True|87849057|87849057|Test|
2|False|103994858|103994858|Production|
3|True|88345576|88345576|Production|
...

Now the master file should have this when finished:

1|True|12094856|12094856|Test|
2|True|12209485|12209485|Production|
3|True|13056733|13056773|Test|
...
56|True|38077408|38077408|Production
57|True|87849057|87849057|Test|
58|False|103994858|103994858|Production|
59|True|88345576|88345576|Production|
...

@TinWalrus I was thinking about the problem this morning, and came to a similar conclusion (though I didn't come up with the code,as awk is completely new to me, so thank you for that). It isn'[t quite the elegant answer I was looking for, but barring a better solution I can make do with that. The issue is that I will be doing this again from time to time, and would prefer appending the new files to the master instead of renumbering them all the time, so the trick I can't figure out is how to tell awk (or sed) to start numbering at a different value than one.

Should be something like this:

awk -F"|" '{$1=NR}1' OFS="|" file1 file2 > file3

Regards

And if for whatever reason $1 does not correspond to NR:

awk > __temp__ -F\|  '
NR == FNR { l = $1; print; next }
$1 = ++l' OFS=\| master temp  &&
mv __temp__ master

Be aware that the code above will overwrite your master file,
so back it up before trying the command.

Thanks for all the help guys (and gals on the off chance that it applies). Both of these last 2 solutions are workable, though radoulov's is closest to what I intended. This will make my life much easier.

nawk 'BEGIN{FS=OFS="|"} {$1=NR;print}' a b c