Labb 3 klar, bara reflektionen kvar att skriva
This commit is contained in:
parent
f766cb61d9
commit
179e1ce823
@ -21,4 +21,14 @@ Declare och test-värden testas lite i början av labben. Exempelvis:
|
||||
|
||||
Detta är ett enkelt sätt att testa olika test-scenarion utan att behöva skapa ett helt nytt script varje gång man vill prova på något bara.
|
||||
|
||||
### Övningsupptifter ###
|
||||
|
||||
Samtliga övningsuppgifter finns här på GitHub
|
||||
|
||||
* [Övning 1](https://github.com/jackbenny/scripts_grundkurs/blob/master/Labb3/ovning1.sh)
|
||||
* [Övning 2](https://github.com/jackbenny/scripts_grundkurs/blob/master/Labb3/ovning2.sh)
|
||||
* [Övning 3](https://github.com/jackbenny/scripts_grundkurs/blob/master/Labb3/ovning3.sh)
|
||||
* [Övning 4](https://github.com/jackbenny/scripts_grundkurs/blob/master/Labb3/ovning4.sh)
|
||||
|
||||
## Reflektion ##
|
||||
|
||||
|
32
Labb3/ovning4.sh
Executable file
32
Labb3/ovning4.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Jack-Benny Persson
|
||||
# LX13
|
||||
# Öving 4, labb 3
|
||||
|
||||
Arg=$1
|
||||
|
||||
# Sanity checks
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "Enter a filename as an argument, such as $0 <filename.txt>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -e $Arg ]; then
|
||||
echo "$Arg does not exist"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
|
||||
# Check whatever arg1 is a block device, directory or a regular file
|
||||
if [ -b $Arg ]; then
|
||||
echo "$Arg is a block device"
|
||||
elif [ -d $Arg ]; then
|
||||
echo "$Arg is a directory"
|
||||
elif [ -f $Arg ]; then
|
||||
echo "$Arg is regular file"
|
||||
else
|
||||
echo "$Arg is something else"
|
||||
fi
|
||||
|
||||
exit 0
|
Loading…
x
Reference in New Issue
Block a user