how to change the content of a file without open it?
I am using condor system to run simulation. Each run I only need to change a number in the input file. For example, for 20 simulations, I have 20 input files. But only a number in the input file is different. How can I change the number without opening each file and changing it manually?
thanks so much. |
If I understand you right then Condor (I presume you're talking about http://www.cs.wisc.edu/condor/) needs to read a number from a file to tell it how many input files it should use per run?
The only way you could do this would be to know how many input files it'll need per run in advance or have some way of calculating it. If you do you could probably just use a script to write a file whenever it detects that a previous job has completed (maybe by going off the number of files output or the contents of a log file?). You may want to set this to run automatically in a cron job. |
Quote:
thanks |
Quote:
sed -i 's/-15/-2035/' filename this works. |
That may lead to some astonishment - it changes all occurrences of "-15" TO "-2035". Maybe you should just change the data you need to the data you want. Note the 3 after the single quote restricts the update to only the third line.
Code:
sed -i '3s/-15/-20/' filename |
Running echo in a shell with output redirection can overwrite file contents. For example:
echo "12" > some-file.txt will overwrite any existing some-file.txt with 12 as it's content. By creating a shell script you can populate all the input files with random numbers. Adding the shell script as a cron job will run it without your interaction. Linux Archive |
All times are GMT -5. The time now is 10:59 AM. |