Lagt till en ny variant av övning 4 samt skrivit reflektion
This commit is contained in:
26
Labb3/ovning4_file.sh
Executable file
26
Labb3/ovning4_file.sh
Executable 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
|
Reference in New Issue
Block a user