Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count the printable characters

I have to create a script ( an one-liner more exactly) that will receive as an argument the link to a directory( ex /home/stan/direct).The directory (in my exemple is direct) contain an
unknown number of directories and files.Those files contain words separated by one ","(comma) ,one " "(space) or one "/n"(new line) .The script must count the printable characters from all those files (exception " " and ",") and print the result and also to redirect all the errors that occur while runing the script in a file named errors.txt. And now my question ? How can i make such a script(one-liner) ?

like image 885
user3026159 Avatar asked Feb 03 '26 08:02

user3026159


1 Answers

First filter out which is not printable, then count what left:

sed 's/[^a-zA-Z0-9]//g'|wc -c
like image 189
peterh Avatar answered Feb 05 '26 09:02

peterh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!