Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to print the last 9 characters

Status
Not open for further replies.

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.
 
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
 
It works fine - and I learned useful things.
Thanks a lot!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top