Hi,
I have the following SGE submission (HPC calculation) script, which is just a Bash script:
#!/bin/bash -l
#$ -S /bin/bash
#$ -l h_rt=1:00:0
#$ -l mem=4G
#$ -N XXX
#$ -pe qlc 24
#$ -P XXX
#$ -wd /home/uccaxxx/Scratch/222PdT/3vac/c0001/
mpirun -m $TMPDIR/machines -np $NSLOTS $HOME/bin/new_vasp
What I'd like to do is take the following line within that script:
#$ -wd /home/uccaxxx/Scratch/222PdT/3vac/c0001/
... looking, specifically, at the 'c0001' element.
I'd then like to, for example, say that I want 101 new scripts like this with only the 'c0001' element in that line changing accordingly. So, I would have 101 scripts where that element changes from c0001 to c0002 ... c0033 ... all the way to c0101.
The script is currently called 'script_0001', and I'd like the new scripts' filenames to change to script_0002 etc. all the way through to script_0101 according to how the c0001 element in the line in question is changed.
Ideally I'd like to produce something that can do what I need in Python or Bash as these are languages I am familiar with.
I started writing something in Bash which fell down and this is what I have in Python so far, which is a long way off and which I have rather hit the wall with:
#!/usr/bin/python
from __future__ import print_function
with open('scriptnew', mode='w') as outfile:
with open('script') as infile:
for line in infile.readlines():
if line[4:6]=='-wd':
a = int(line[42])
line = line[42] + int(a)
print(line, end='', file=outfile)
Any help (or statements informing me that this not at all simple) would be greatly appreciated.