ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
i have a very tedious task to be automated:
i am running a computational analysis, and i need to edit MANY time the coordinates on a file..
the file is a txt, and the coordinate to be edited are those:
lines before (which i don't need to edit) SDEF pos= x y z blabla blablabla
lines after (which i don't need to edit)
i need to edit them taking from a list of coordinates in another file txt i can provide; and the script should output N new files (where N is the number of coordinates i have to examine) each one with a tag number (example sample1, sample2..)
So in short it should edit a file N times, saving each time it edits with a different name.
please help me i have to edit 3580 times the file, the coordinates needed are just 70 but i've to consider many different cases..
the file with the coordinates is a 70 lines simple TXT file made like that:
1 x y z
2 x y z
3 x y z
where the line number should be used in the output file name.
i need only 70 output files because this is the most tedious work:
i am calculating for energy ranges so what i do is basically this, i choose an energy range and write to the file
then i make 70 files for all the coordinates and launch the analysis
once is done i collect the data in a excel sheet and i pass to the next energy by editing the main file
then again i make 70 files out of the template changing only the coordinates.
and so on..
what i need the script for is avoiding the work of editing 70 times the main file, by getting 70 duplicate files where only the coordinate value has been changed..
i need 3580 analisys in total but this i need to do myself, the important is automating the coordinate change or i will get crazy or very likely make an error..
Last edited by assasukasse; 10-25-2006 at 04:55 AM.
i found a small problem with the script:
if i choose a clearly wrong file as a template for the coordinates
it tells me that maybe i am wrong since there are letters too
but proceed anyway making a bunch of wrong files...
is there any way to stop the generation of files in case a letter is encountered?
hi bigersbilli i incurred in a small problem
i have the need to process files that have tabs instead of spaces between the coordinates.
or even better, to ignore if there is 1-4-5-6 or whatever spaces in between the numbers, or even tabs..
do i need to change anything?
Last edited by assasukasse; 01-04-2007 at 03:36 PM.
i need more time to study sed, i made some tests but i didn't go much farther..
however, i was thinking i missed something when in the file bigearsbilly gave me:
there is another line that needs to be edited
the line is BEFORE the SDEF line
and starts with 14 RCC then 5 spaces, then the same coordinates of SDEF then other numbers..
now i added the following line to the pl file: