LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-02-2010, 12:18 AM   #1
simpleman0982
LQ Newbie
 
Registered: Nov 2010
Posts: 3

Rep: Reputation: 0
Save the results of a fortran loop in a text file


Hi,
I am trying to store the results of my code to a separate text file.But the problem is, as my results comes from a loop, my text file shows only the last result, not all of them.Like if the loop runs 5 time the text file shows the result for the 5th step.But i need to store all of them (1 to 5).Can I use awk to print the output field and store to another file and creat a new line so that the next output field goes to a new line?(just an idea, dont know).Could anyone help me? I am very new in linux as well as fortran, any help is greatly appreciated.Thank you

#!/bin/basth
for (( i=1; i<=5; i++))
do
./file.exe > output.txt
done
 
Old 11-02-2010, 01:18 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

The shell ">" operator redirects to a new text file.

The ">>" operator, however, lets you ADD to an EXISTING file:
Code:
#!/bin/bash
for i in {1..5}
do
  ./file.exe >> output.txt
done
'Hope that helps!

Last edited by paulsm4; 11-02-2010 at 01:21 AM.
 
Old 11-02-2010, 11:40 PM   #3
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
PS:
What's "#!/bin/basth"? Most Linux distros use "bash". Bash is a full-featured shell - but it uses a slightly different "for loop" syntax than you're using.

I'd encourage you to look into "bash", if you're not already familiar with it:

http://www.ibm.com/developerworks/library/l-bash.html
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to loop over text file lines within bash script for loop? johnpaulodonnell Linux - Newbie 9 07-28-2015 03:49 PM
gedit cannot save text file, type mailbox file ! snailchess Linux - Newbie 10 02-26-2011 04:57 AM
[SOLVED] Output to a text file, the results of compound command Herbivore Linux - General 5 07-28-2010 10:38 AM
Running make menuconfig results in text file is busy. jerel4565 Linux - Kernel 2 07-18-2009 10:40 PM
Loop over lines in text file? amaze Linux - General 2 08-12-2003 07:15 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration