Test with reading from file
This commit is contained in:
parent
c6d3634931
commit
a0adf95d86
23
Misc/from_file.sh
Executable file
23
Misc/from_file.sh
Executable file
@ -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` <filename>"
|
||||||
|
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
|
Loading…
x
Reference in New Issue
Block a user