How to generate a temp file until finish selected then replace to another file.

Reply

Join Date: Nov 2008
Posts: 2
Reputation: ckcy2005 is an unknown quantity at this point 
Solved Threads: 0
ckcy2005 ckcy2005 is offline Offline
Newbie Poster

How to generate a temp file until finish selected then replace to another file.

 
0
  #1
Nov 6th, 2008
Hi All,

I am facing a problem. I need to do a script which to generate the temp.txt file first when select from database, until the data finish store into temp file then -> MV temp.txt to finish.txt.

Any idea? or any sample script for me to refer? I am shell script beginner. Thank you
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 399
Reputation: chris5126 is an unknown quantity at this point 
Solved Threads: 14
chris5126 chris5126 is offline Offline
Posting Whiz

Re: How to generate a temp file until finish selected then replace to another file.

 
0
  #2
Nov 6th, 2008
Ot create a file and pipe something into it whatever you like you can use the redirect to a file

Shell Scripting Syntax (Toggle Plain Text)
  1. echo "hello" > /tmp/temp.txt
This will open a new file or overwrite an existing file in the same location and then put the text hello into /tmp/temp.txt. If you want to add addtional lines use the following command
Shell Scripting Syntax (Toggle Plain Text)
  1. echo "hello chris" >> /tmp/temp.txt
You file will then contain hello followed by hello chris to move this file from one location to the other use the following code
Shell Scripting Syntax (Toggle Plain Text)
  1. mv location1 location2
  2. e.g
  3. mv /tmp/temp.txt /tmp/finished.txt
If my post helped add to my rep!
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 2
Reputation: ckcy2005 is an unknown quantity at this point 
Solved Threads: 0
ckcy2005 ckcy2005 is offline Offline
Newbie Poster

Re: How to generate a temp file until finish selected then replace to another file.

 
0
  #3
Nov 7th, 2008
oooic... I get what ur means already...
Done liao..
haha..!!
thank you chris5126
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 61
Reputation: Gromit is an unknown quantity at this point 
Solved Threads: 7
Gromit's Avatar
Gromit Gromit is offline Offline
Junior Poster in Training

Re: How to generate a temp file until finish selected then replace to another file.

 
0
  #4
Nov 7th, 2008
Do you use the temporary file for anything in the meantime? I'm biased against temporary files when they can be avoided, personally... Why not stuff it all into a variable and then stuff it into a file when it's done, or just write directly to the destination file? Here's an example of using a variable:

Shell Scripting Syntax (Toggle Plain Text)
  1. ## the quotes are important!
  2. RESULT="$(command --switches)"
  3. echo "$RESULT" > /tmp/finished.txt

Hope that helps!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Shell Scripting Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC