From a0adf95d86d62525a69438d8abc809dc6d551381 Mon Sep 17 00:00:00 2001 From: Jack-Benny Persson Date: Sun, 15 Dec 2013 20:00:07 +0100 Subject: [PATCH] Test with reading from file --- Misc/from_file.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 Misc/from_file.sh diff --git a/Misc/from_file.sh b/Misc/from_file.sh new file mode 100755 index 0000000..23304c9 --- /dev/null +++ b/Misc/from_file.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Jack-Benny Persson +# LX13 +# Testing to read from a file + +Counter=1 +if [ $# -ne 1 ]; then + echo "Usage: `basename $0` " + exit 2 +fi + +if [ ! -r $1 ]; then + echo "Can't read $1" + exit 2 +fi + +cat "$1" | while read line; do + echo "Line $Counter: $line" + ((Counter++)) +done + +exit 0