bash - How to get the length of each word in a column without AWK, sed or a loop? -


this question has answer here:

is possible? have one-liner count number of words in file. if output have looks this:

3 abcdef 3 abcd 3 fec 2 abc 

this done in 1 line without loops , thinking if add column length of each word in column. thinking use wc -m count characters, don't know if can without loop?

as seen in title, no awk, sed, perl.. old bash.

what want:

3 abcdef 6 3 abcd 4 3 fec 3 2 abc 3 

where last column length of each word.

while read -r num word;     printf '%s %s %s\n' "$num" "$word" "${#word}" done < file 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -