Question: using shell script. i need to create script call lengthof.lines which display the length of the each line of input on `stdin`. using 'while' and
using shell script.
i need to create script call lengthof.lines which display the length of the each line of input on `stdin`. using 'while' and 'read', followed by the `==`, followed by the sum of the reported lengths.
Each output is one per line.
(Example)
1. ``` lengthof.lines < /dev/null == 0 ``` 2. ``` echo | lenthof.lines 0 == 0 ``` 3. ``` echo a | lengthof.lines 1 == 1 ``` 4. ``` echo abc | lengthof.lines 3 == 3 ``` 5. ``` echo ' 3x3 spaces ' | lengthof.lines 18 == 18 ``` 6. ``` printf '%s ' a abc | lengthof.lines 1 3 == 4 ``` 7. ``` printf -- '%s ' -e \' \" \\ \* ' ' | lengthof.lines 2 1 1 1 1 2 == 8 ``` 8. ``` printf 'one newline' | lengthof.lines 3 7 == 10 ```
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
