-
Notifications
You must be signed in to change notification settings - Fork 0
/
showfile.sh
executable file
·45 lines (35 loc) · 1.13 KB
/
showfile.sh
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
# showfile--Shows the contents of a file, including additional useful info
#
# 29 Displaying a File with Additional Information (Wicked Cool Shell Scripts)
. "$SK/color.sh"
colors
width=80
for input
do
lines="$(wc -l < $input | sed 's/ //g')"
chars="$(wc -c < $input | sed 's/ //g')"
owner="$(ls -ld $input | awk '{print $3}')"
created="$(stat -f "%SB" $input)"
modified="$(stat -f "%Sm" $input)"
echo "-----------------------------------------------------------------"
echo "File - $input"
echo "Created - $created"
echo "Modified - $modified"
echo "Lines - $lines"
echo "Chars - $chars"
echo "Owner - $owner"
echo "-----------------------------------------------------------------"
linecount="1"
while read line
do
if [ ${#line} -gt $width ] ; then
echo "$line" | fmt | sed -e '1s/^/ /' -e '2,$s/^/+ /'
else
echo -e "${purple}${linecount}${reset}: $line"
fi
linecount="$(( $linecount + 1 ))"
done < $input
echo "-----------------------------------------------------------------"
done
exit 0