Lagt till en ny variant av övning 4 samt skrivit reflektion

This commit is contained in:
2013-12-11 16:41:40 +01:00
parent 179e1ce823
commit 348d00d7f9
2 changed files with 30 additions and 0 deletions

26
Labb3/ovning4_file.sh Executable file
View File

@@ -0,0 +1,26 @@
#!/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
# Using _file_ to test the filetype
Type=`file $Arg | sed "s/$Arg\:\ //"` # Only works for files in CWD because of /
# Print the file type
echo "$Arg is a $Type file"
exit 0