diff --git a/Labb4/ovning3_ver1.sh b/Labb4/ovning3_ver1.sh new file mode 100755 index 0000000..cae6599 --- /dev/null +++ b/Labb4/ovning3_ver1.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Jack-Benny Persson +# LX13 +# Övning 3, version1, labb 4 +# Replace and count words + +# Define some variables +File="$1" +Old="$2" +New="$3" + +# Sanity checks +if [ $# -ne 3 ]; then + echo "Usage $0 " + exit 2 +fi + +if [ ! -r $File ]; then + echo "We can't read that file" + exit 2 +fi + +# Main script +Data=`cat $1` +Alt=${Data/$Old/$New} + +echo "$Alt" + +exit 0 diff --git a/Labb4/test.txt b/Labb4/test.txt new file mode 100644 index 0000000..74a8e7b --- /dev/null +++ b/Labb4/test.txt @@ -0,0 +1,2 @@ +Test jag hej +Ny rad