Need help in inserting a value.........

Hello,

I'm having a files with variable no of lines. An example for this file is as follows

~xxx
STRT 0.0000000000 :
STOP :
~xxxxx
0.000000 557.109552 -557.109552
1511.482910 -954.373377 954.373377

in the STOP line below the 0.00000000000 I need the first coloumn of the last line ie in this case 1511.482910. In each file the value will be changing.
I'm having more than 500 of such files.
I believe a shell script or awk can handle this. Please help me.

If the line you want is the last line of the file:

tail -n1 "$FILE" | cut -f1

If not, how do you determine which line you want?

for finding out the value of the last line's first coloumn I will use
awk '{field = $1 }; END {print field}' filename
but my need is to print this value next to STOP.

Do you mean like this?

awk '{field = $1 }; END {print "STOP",field}' filename

If not... your requirement still isn't clear.

hope below one can help, it suppose all your files are named with .txt suffix.

for i in `ls *.txt`
do
	val=`cat $i | tail -1 | awk '{print $1}'`
	nawk -v val="$val" '{
		if(index($0,"STOP")!=0)
			print $0"  "val
		else
			print
	}' $i
done

It would have been easier for willing repliers
if you had provided us with line numbers so that it gets conspicuous what characters still belong to the same line.
This is rather ambiguous

Depending whatever you consider a valid field separator for this file
if it really is in the same STOP line,
it should be as simple as e.g.

$ awk -F' : ' '$1~/^STOP/{print$2}' file_to_parse

But I guess this wasn't meant?
If it were on the other hand on a different line following the STOP marker
(can't fathom what ~xxxxx shall denote) then you would have to parse this line.
Sticking with the assumed line count, and assuming GNU grep was available
you could then maybe do something like

$ grep -A3 ^STOP file_to_parse|tail -1|cut -d\  -f1

But I don't want to fall prey to era's useless use content here,
why this could better be accomplished in a single awk statement
after you have told us how the line counting goes.

You haven't answered the question: How do you determine which line contains the value?

In the example you gave, that line is not "next to STOP".

Hi Summer Cherry,

It worked fine, even though I made some minor formatting Change...............

Thanks a lot......................

Regards,
Santy

Not only is ls unnecessary, but it will break the script if there is whitespace in any of the filenames. It should be:

for i in *.txt

The OP was not clear whether the line in question was the last of the file; that only works if it is.

Also, there is no need for cat or tail:

val=`awk 'END {print $1}' "$i"`