starlite79
Technical User
Hi everyone.
I'm fairly new to AWK, but from what I've read I think it can do some powerful things if I know what I'm doing.
I would like to be able to substitute two fields in one file (a Fortran program I wrote) with the same fields from a C program that is very similar.
Here is one line from each file:
C file line:
vvd(test(-0.1), 6.183185307179586477, 1e-12, "test", "a", status);
Fortran file line:
CALL VVD ( test ( -0.1D0 ), 6.183185307179587D0,
: 1D-12, 'test', 'A', STATUS )
I began with writing a simple awk program to make the field separator a comma and print the second field as so:
BEGIN { FS = "," # make comma the field separator
}
$1 ~ /VVD/ { print $2
}
The C file has records which take only one line. On the other hand, the Fortran program (to conform to the 72 character requirement of my colleague) has records that have multiple lines (indicated by the continuation character . I only am concerned about the second and third fields and need to know how to make ; the record separator for the one file and something else (maybe a newline?) for the second.
Any help would be very much appreciated.
I'm fairly new to AWK, but from what I've read I think it can do some powerful things if I know what I'm doing.
I would like to be able to substitute two fields in one file (a Fortran program I wrote) with the same fields from a C program that is very similar.
Here is one line from each file:
C file line:
vvd(test(-0.1), 6.183185307179586477, 1e-12, "test", "a", status);
Fortran file line:
CALL VVD ( test ( -0.1D0 ), 6.183185307179587D0,
: 1D-12, 'test', 'A', STATUS )
I began with writing a simple awk program to make the field separator a comma and print the second field as so:
BEGIN { FS = "," # make comma the field separator
}
$1 ~ /VVD/ { print $2
}
The C file has records which take only one line. On the other hand, the Fortran program (to conform to the 72 character requirement of my colleague) has records that have multiple lines (indicated by the continuation character . I only am concerned about the second and third fields and need to know how to make ; the record separator for the one file and something else (maybe a newline?) for the second.
Any help would be very much appreciated.