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!

Convert to digit

Status
Not open for further replies.

nguyenb9

Technical User
Apr 1, 2003
55
US
I have a file look like:

HOD2|741|301||Y|
HOD2|751|30144||Y|
HOD2|761|3012||Y|

I want the third field to be coverted into how many digits in that field.

Result:
HOD2|741|3||Y|
HOD2|751|5||Y|
HOD2|761|4||Y|

Thank you for you help.
 

Try

BEGIN {OFS=FS="|"}
{
$3=length($3)
print
}

CaKiwi

"I love mankind, it's people I can't stand" - Linus Van Pelt
 
Are you sure?
[pun intended]

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top