checks for layout

This commit is contained in:
waldek 2021-04-10 14:07:05 +02:00
parent 1bf0caa082
commit 5912945ed0
1 changed files with 33 additions and 30 deletions

View File

@ -125,42 +125,45 @@ fi
## Guided Exercises
1. Read the contents of script1.sh below:
```
#!/bin/bash
if [ $# -lt 1 ]
then
echo "This script requires at least 1 argument."
exit 1
fi
```
#!/bin/bash
echo $1 | grep "^[A-Z]*$" > /dev/null
if [ $? -ne 0 ]
then
echo "no cake for you!"
exit 2
fi
if [ $# -lt 1 ]
then
echo "This script requires at least 1 argument."
exit 1
fi
echo $1 | grep "^[A-Z]*$" > /dev/null
if [ $? -ne 0 ]
then
echo "no cake for you!"
exit 2
fi
echo "here's your cake!"
exit 0
```
echo "here's your cake!"
exit 0
```
* What is the output of these commands?
```
./script1.sh
echo $?
./script1.sh cake
echo $?
./script1.sh CAKE
echo $?
```
./script1.sh
echo $?
./script1.sh cake
echo $?
./script1.sh CAKE
echo $?
```
2. Read the contents of file script2.sh:
```
for filename in $1/*.txt
do
cp $filename $filename.bak
done
```
```
for filename in $1/*.txt
do
cp $filename $filename.bak
done
```
* Describe the purpose of this script as you understand it.
## Explorational Exercises