Börjat på övning 3, labb 4

This commit is contained in:
Jack-Benny Persson 2013-12-12 20:00:44 +01:00
parent 0c16c0bdd2
commit 6164767b87
2 changed files with 32 additions and 0 deletions

30
Labb4/ovning3_ver1.sh Executable file
View File

@ -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 <filename> <old_word> <new_word>"
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

2
Labb4/test.txt Normal file
View File

@ -0,0 +1,2 @@
Test jag hej
Ny rad