python - Using sed in a Jython script to replace a whole line with a variable in a text file -


in jython script trying replace entire line of text file (the 2nd line in case) directory address contains variable (var).

obsids=str(obsids[i]) print type(obsids) os.system('sed -i "2 s:.*:/usr/data/$obsids/:" /usr/software/file.txt') 

where obsids unicode of whole number, string (usually 1342204440).

please can show me error in script.

thanks.

we got in comments:

obsids=str(obsids[i]) print type(obsids) os.environ['obsids']=obsids  # makes python variable behave inside unix os.system('sed -i "2 s:.*:/usr/data/$obsids/:" /usr/software/file.txt') 

Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -