Email Subscription Notifications Suspended Temporarily
We are in the process of making navigation in the Servers and Operating Systems forums simpler and more direct. While doing this, we have to temporarily suspend email notifications for subscriptions. If you are subscribed to one or more discussion boards or blogs in the community, please check them daily to see new content. Notifications will be turned back on in a few days. We apologize for any inconvenience this may cause. Thanks, Warren_Admin
StoreEver Tape Storage
Showing results for 
Search instead for 
Did you mean: 

char count script

Go to solution
Jimmy Roux_1

char count script

Do you have a script that will count the number of characters per line of the output of "swlist -l file"?

For example:

Perl5.PERL-MAN: /opt/perl/man/man3/B::Concise.3
Perl5.PERL-MAN: /opt/perl/man/man3/B::Debug.3
Perl5.PERL-MAN: /opt/perl/man/man3/B::Deparse.3
Perl5.PERL-MAN: /opt/perl/man/man3/B::Disassembler.3

The script goes through each line above, disregard the start of each line up to the last "/" character, then count the rest of the characters of each line. If the character count on that line is greater than 30, print the filename and the actual character count.


Masatake Hanayama
Trusted Contributor

Re: char count script

# tested on HP-UX 10.20
swlist -l file | awk -F/ '
if (NF > 1) wkstr=$NF
if (wklen > 30) printf("%4d %s\n",wklen,wkstr)