Jan 16, 2003 #1 irixfan IS-IT--Management May 14, 2002 57 FI How to print the last 9 characters of $1 and then $2 completely? Input file has multiple lines, two strings on each.
How to print the last 9 characters of $1 and then $2 completely? Input file has multiple lines, two strings on each.
Jan 16, 2003 #2 olded Programmer Oct 27, 1998 1,065 US Irixfan: Use awk's sub string function: awk ' { cnt=length($1) f1=substr($1, cnt-8, cnt) # get last 9 characters of field 1 printf("%s %s\n",f1, $2) } ' data.file Regards, Ed Upvote 0 Downvote
Irixfan: Use awk's sub string function: awk ' { cnt=length($1) f1=substr($1, cnt-8, cnt) # get last 9 characters of field 1 printf("%s %s\n",f1, $2) } ' data.file Regards, Ed
Jan 17, 2003 Thread starter #3 irixfan IS-IT--Management May 14, 2002 57 FI It works fine - and I learned useful things. Thanks a lot! Upvote 0 Downvote