Editting a record

robert

Will the 0 always start at same position, so this is the actual number 00001453 . If not, the is some difficult since your tail do contain several group of 0

Try:

a=1453
sed -n "\$s/[1-9]*\$/$a/p" file

@Don: applying your code snippet to a file containing requestor's line yields

$ sed -n "\$s/[1-9]*\$/$a/p" file
1453290070331000012923

Am I missing sth?

EDIT: Yes I did! That input sample above had a <CR> char in it causing that strange result. Using Don's code on a normal unix file works as expected - his reputation fully rehabilitated... Sorry for me falling into that trap.

I came up with

$ sed  "$ s:[^0]*$:$a:" file
.
.
.
T005290070331000012923
T005290070331000012923
T00529007033100001453

as the request left open if the entire file should be reproduced or just the modified last line.

EDIT 2: neither proposal works if there is a 0 contained within that last 5 digit number, e.g. 12023...

Hi Rudi,
I used sed -n because the requested output in the 1st message in this thread only showed one line.

From the way the request was worded, I'm not even sure if there is more than one line in the input file. (I don't know if "tail" refers to the last line in the file or to the end of the last (and maybe only) line in the file.

robert

What about considering all the proposals - that, btw, satisfy your original requirements - and develop a "better" code yourself? On top, your specification left quite some questions open that occurred in the discussion - pls answer them first.