So i have all these words in a text file:
dfasdfasdf
adsgad
fghjast
hdasfh
adfhadfn
And i have to display the number of chars of the smallest word without using the 'awk' and 'sed' commands... I have tried all variants of wc but it works with the full text file and not only line per line.
Edit: I apologize for not giving more details on the subject. I am learning Shell basics and have not started programming on Linux yet. The point on this exercise that i Have is to show in the screen how many characters that the shortest word has. To this point I have only learned the commands tr, cp, cut, sort, head, tail, grep, find,wc... So I can't use awk/sed/any other command that I have learned on the internet or programming on this...
sort
? – choroba Oct 30 '18 at 19:55mapfile -t arr < yourtextfile; for f in "${arr[@]}"; do printf '%s\n' "${#f}"; done | sort -n |head -n1
or using theread
as follows:while read -r line; do printf '%s\n' "${#line}"; done < fff | sort -n | head -n1
– Valentin Bajrami Oct 30 '18 at 20:01