pk wrote:
> Dieter Kraft wrote:
>
>>> Now I have the problem to append a line
>>> to my 1000 model files *.mod
>>> which all have the entry
>>> solve;
>>> as their hitherto last line.
>>> The last line (after the solve; line) shall now look like
>>> printf : "%s %5i %5i %5i %5i %10.5f %10.5f \n", *, N, M, IERR, ITER,
F,
>>> _solve_time >> TABLE.TEX;
>>>
>>> where the * in this line should be the * from *.mod above.
>
> If I understand it correctly, you have 1000 files whose name ends in
.mod,
> the last line of each file being "solve;". For each file, you want to
> append a line after the "solve;" line, and, in this new line, the "*"
> should be replaced with the filename (without the .mod).
> Note that, If I understand correctly, the information that the last line
is
> currently "solve;" is superfluous, since you want to append the new line
at
> the end anyway.
>
> If this is correct, then
>
> cd /dir/with/mod/files
> for name in *.mod; do
>
> # basename without suffix
> bname=${name%.mod}
>
> # line to append; must be all on a single line
> line="printf : \"%s %5i %5i %5i %5i %10.5f %10.5f \\n\", $bname, N,
M,
> IERR, ITER, F, _solve_time >> TABLE.TEX;"
>
> # appends the new line at the end of the file
> printf "%s\n", "$line" >> "$name"
> done
>
>
>
Thanks, it does what I (respectively ampl www.ampl.com) want if I do two
changes
line="printf : \"%s %5i %5i %5i %5i %10.5f %10.5f \\n\", ' $bname ', N,
$bname as a string and
printf "%s\n" "$line" >> "$name"
no comma
Thanks again
Dieter
--
Dieter Kraft
Munich University of Applied Sciences
Department of Mechanical Engineering
dieter.kraft@[EMAIL PROTECTED]


|