Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

insert line once again
> Hi,
>
> thanks for your previous help, pk and Stephane.
>
> 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.
>
> Thanks again
> Dieter


--
Dieter Kraft
Munich University of Applied Sciences
Department of Mechanical Engineering
dieter.kraft@hm.edu
www.lrz-muenchen.de/~dkraft

Report this thread to moderator Post Follow-up to this message
Old Post
Dieter Kraft
03-27-08 09:01 AM


Re: insert line once again
On 3/27/2008 2:10 AM, Dieter Kraft wrote: 

Assuming I don't need any context from a previous post:

base=FILENAME
sub(/.mod$/,"",base)
printf "%s %5i %5i %5i %5i %10.5f %10.5f \n", base, N, M, ...

Ed.



Report this thread to moderator Post Follow-up to this message
Old Post
Ed Morton
03-28-08 12:00 AM


Re: insert line once again
pk wrote:
> Dieter Kraft wrote:
> 
>
> 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 i
s
> currently "solve;" is superfluous, since you want to append the new line a
t
> 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@hm.edu
www.lrz-muenchen.de/~dkraft

Report this thread to moderator Post Follow-up to this message
Old Post
Dieter Kraft
03-28-08 12:00 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

AWK archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 03:53 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.