Oct 28, 2004 #1 eholdo Technical User May 30, 2002 31 US need to find a way to return the byte position of a string within a file. csh method is needed. Thanks!
need to find a way to return the byte position of a string within a file. csh method is needed. Thanks!
Oct 28, 2004 #2 scriptdan Technical User Oct 11, 2004 15 US Try nawk Code: nawk 'BEGIN {bytepos=0}{sumlinebytes+=length($0);strpos=match($0,"[COLOR=red]yourstring[/color]");if (strpos) {bytepos=sumlinebytes+strpos-length($0);exit} } END {print bytepos}' [COLOR=red]yourfile[/color] Upvote 0 Downvote
Try nawk Code: nawk 'BEGIN {bytepos=0}{sumlinebytes+=length($0);strpos=match($0,"[COLOR=red]yourstring[/color]");if (strpos) {bytepos=sumlinebytes+strpos-length($0);exit} } END {print bytepos}' [COLOR=red]yourfile[/color]