mirror of
https://github.com/Hizenberg469/Makefile-tutorial.git
synced 2026-04-19 22:02:24 +03:00
created shell dir
This commit is contained in:
25
shell/print.sh
Normal file
25
shell/print.sh
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
#create script for printing files, which will display
|
||||
#also line numbers
|
||||
|
||||
#argument check
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "Exactly one arugment is needed, run: $0 file-path"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#check if provided argument is a file
|
||||
if ! [ -f "$1" ]; then
|
||||
echo "File you've specified doesn't exist"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
FILENAME=$1
|
||||
COUNT=1
|
||||
|
||||
while read line
|
||||
do
|
||||
echo "$COUNT: $line"
|
||||
let COUNT++
|
||||
done < "$FILENAME"
|
||||
Reference in New Issue
Block a user