jobe /var/www/html/index.html /var/www/html/jobe Write a shell script that takes the name of such a text file as an argument and shows its content For example:
| Test | Input | Result |
|---|---|---|
| # Test 1 | data1.txt | jobe |
| /var/www/html/index.html | ||
| /var/www/html/jobe |
Answer:
fname=$1
showcont=`cat $fname`
echo "$showcont"\
Write a shell script that takes arguments as a string of multiple words separated by spaces, and prints the words one per line.
For example:
| Test | Input | Result |
|---|---|---|
| # Test 1 | a ab abc | a |
| ab | ||
| abc |
Answer:
for words in $*; do
echo "$words"
done
For example:
| Test | Input | Result |
|---|---|---|
| Test case 1 | a | matched |
| Test case 2 | b | not matched |
Answer:
[^b-z]
For example:
| Test | Input | Result |
|---|---|---|
| Test1 | abcdefg | matched |
| Test2 | gabcdef | matched |
| Test3 | defg | not matched |
| Test4 | gadbec | not matched |
Answer:
[abcdefg]{7}