Oct 28, 2004 #1 eholdo Technical User Joined May 30, 2002 Messages 31 Location 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 Joined Oct 11, 2004 Messages 15 Location 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]