-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path032-showfile.sh
More file actions
27 lines (22 loc) · 751 Bytes
/
Copy path032-showfile.sh
File metadata and controls
27 lines (22 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh
# showfile - show the contents of a file, including additional useful info
width=72
for input
do
lines="$(wc -l < $input | sed 's/ //g')"
chars="$(wc -c < $input | sed 's/ //g')"
owner="$(ls -ld $input | awk '{print $3}')"
echo "-----------------------------------------------------------------"
echo "File $input ($lines lines, $chars characters, owned by $owner):"
echo "-----------------------------------------------------------------"
while read line
do
if [ ${#line} -gt $width ] ; then
echo "$line" | fmt | sed -e '1s/^/ /' -e '2,$s/^/+ /'
else
echo " $line"
fi
done < $input
echo "-----------------------------------------------------------------"
done | more
exit 0