\while read line; do [[ ${#line} -gt ${#max} ]] && max=$line; done </etc/profile; \echo ${#max}: $max70: # /etc/profile: system-wide .profile file for the Bourne shell (sh(1))The trick here is using the bash built-in ${#variable}, which returns the number of characters in the string in $variable (unless the variable is an array, in which case it returns the number of elements in the array)