You are on page 1of 2

if [ $# -eq 3 ]; then

if [ -e $3 ]; then
tail +$1 $3 | head -n$2
else
echo "$0: Error opening file $3"
exit 2
fi
else
echo "Missing arguments!"
fi

#!/bin/sh
sed -n 's/'"$1"'/&/p'

echo -n "Enter a filename to see last modification time : "


read fileName
 
# make sure file exits
if [ ! -f $fileName ]
then
echo "$fileName not a file"
exit 1
fi
 
# use stat command to display
echo "$fileName was last modified on $(stat -c %x $fileName)"

FILE="$1"
 
# make sure we got file-name as command line argument
if [ $# -eq 0 ]
then
echo "$0 file-name"
exit 1
fi
 
which stat > /dev/null
 
# make sure stat command is installed
if [ $? -eq 1 ]
then
echo "stat command not found!"
exit 2
fi
 
# make sure file exists
if [ ! -e $FILE ]
then
echo "$FILE not a file"
exit 3
fi
 
# use stat command to get info
echo "Time of last access : $(stat -c %x $FILE)"
echo "Time of last modification : $(stat -c %y $FILE)"
echo "Time of last change : $(stat -c %z $FILE)"

find . -size +40k -ls


-rw-rw-r-- hermie users 56720 Jan 16 12:42 bigfile
-rw-rw-r-- hermie users 415206 Feb 27 21:37 largefile
-rw-rw-r-- hermie users 315428 Jan 07 05:23 hugefile

#!/bin/bas
h
FILENAME=/
home/heiko
/dummy/pac
kages.txt
FILESIZE=$
(stat -c%s
"$FILENAME
")
echo "Size
of
$FILENAME
=
$FILESIZE
bytes."

FILESIZE=$
(stat -c%s
"$FILENAME
")

You might also like