0

Hi folks

I have tried posting this in the python forum without any luck (http://www.daniweb.com/forums/post1120606.html#post1120606), as well as on the official Intel Fortran forum (because I have also attempted it in Fortran). I am not one inch closer to solving this.

All I want is to be able to overwrite, with the value of a variable I have read in, whatever text in a given text file is on a specific line and specific position on that line.

Text on all other lines, and on the edited line before and after the specified position on that line, MUST remain unchanged (obviously the actual position on the line would be a range for words or non-single-digit numbers).

This is an old-school Fortran input file, presumably based on punch-card style inputs, hence the need to maintain the physical structure of the input file at all costs. I merely want a script or some code that will permit me to change a value within the input file automatically.

This is driving me insane.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by cfajohnson
0
file=$1
line=$2
old=$3
new=$4

awk -v line="$line" -v old="$old" -v new="$new" '
 NR == line { sub( old,new ) }
            { print }
' "$file"
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.