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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

awk -F: '{ print length() }' test.dat | sort -u

Status
Not open for further replies.

vuakhobo

Technical User
Apr 22, 2004
41
0
0
US
Hello all,
I need little help.
I have a flat file called test.dat with 4 lines in it:
fddkdjfdkdkfkdf
ddd
fddkdjfdkdkfkdf
ddddd

when I run awk -F: '{ print length() }' test.dat | uniq -c
the result show:
1 15
1 3
1 5

What I really want is if the line have the length increment the count. The result should look like
2 15
1 3
1 5

where in the
awk -F: '{ print length() }' test.dat | sort -u
I should add the count to produce the result that I want
 
I found my answer:
run in linux:
awk -F: '{ print length() }' $1 | sort --key=1 | uniq -c
run in aix

awk -F: '{ print length() }' $1 | sort +1 | uniq -c
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top