Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/awk -f
- BEGIN {
- FS ="$"
- }
- {
- n = NF;
- while ( n > 0 ) {
- if ( $n == "" ) {
- break;
- }
- if ( match($n, /(([[:alpha:]]\w*)|([[:digit:]]+))/) > 0 && ( $(n-1) !~ /\'$/i || n-1 == 0 ) ) {
- #find char position of reference relative to line (record).
- i = 1;
- c = 1; #counter for $ in line ($0)
- while ( c != n) {
- if ( substr($0, i, 1) == "$" ) {
- c++;
- }
- i++;
- }
- #output the match string line position and line number
- if ( ( i - 2 > 0 && substr($0, i - 2, 2) ~ /^[^\$]\$$/ ) ) {
- print substr($n, RSTART, RLENGTH), i, NR;
- } else if ( (i - 2 == 0 && substr($0, i-1, 1) == "$" ) ){
- print substr($n, RSTART, RLENGTH), i, NR;
- }
- }
- n--;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement