echo "What do you want to do - "
echo "1. Search a given pattern."
echo "2. Search according to file size."
echo "3. Search according to date."
echo "Enter your choice - "
read n
if [ $n -eq 1 ];
then
echo "Enter the pattern - "
read pat
for i in *
do
a=`grep "$pat" $i | wc -l`
if [ $a -gt 0 ];
then
echo $i
fi
done
elif [ $n -eq 2 ]
then
echo "Enter maximum size of file - "
read max
echo "Enter minimum size of file - "
read min
ls -lr | awk '$5<='$max' && $5>='$min' {
print $9}'
elif [ $n -eq 3 ]
then
echo "Enter the date in order yyyy-mm-dd : "
read dt
ls -lr | awk '$6 ~ /'$dt'/ {
print $9}'
else
echo "Invalid option."
fi