You've already forked devops-exercises
Rename exercises dir
Name it instead "topics" so it won't be strange if some topics included "exercises" directory.
This commit is contained in:
24
topics/shell/solutions/count_chars.md
Normal file
24
topics/shell/solutions/count_chars.md
Normal file
@@ -0,0 +1,24 @@
|
||||
## Count Chars
|
||||
|
||||
### Objectives
|
||||
|
||||
1. Read input from the user until you get empty string
|
||||
2. For each of the lines you read, count the number of characters and print it
|
||||
|
||||
### Constraints
|
||||
|
||||
1. You must use a while loop
|
||||
2. Assume at least three lines of input
|
||||
|
||||
### Solution
|
||||
|
||||
```
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo -n "Please insert your input: "
|
||||
|
||||
while read line; do
|
||||
echo -n "$line" | wc -c
|
||||
echo -n "Please insert your input: "
|
||||
done
|
||||
```
|
||||
Reference in New Issue
Block a user