Header Ads

Header ADS

Show recent files in Backtrack

Show recent files in Backtrack

Write a script, which lists the most recent file in a directory, if user type recent <Return> then names of the ten most recently modified files are displayed . If the user types recent n <Return> then names of the n most recently modified files are displayed otherwise, the user is notified of incorrect usage.

Code

#!/bin/bash
cd /root/noman2/temp
let "a =1";
while test $a -eq 1;
do
clear
echo " === Recent Files Program == "
echo " "
echo "Chose from the following options: "
echo " Enter 'm' to view the last modified file"
echo " Enter 'recent' to view last 10 recent files"
echo " Enter 'recent n' to view last n recent files"
echo " Enter 'q' to quit "
echo ""
echo "Enter your Option"
read c
clear
case $c in
m)
ls -tr | tail -1
read x
;;
recent)
ls -t | head
read x
;;
q)
exit 0
;;
*)
v1=${c#* }
if (ls -t | head -n $v1); then
read x
else
echo "Please enter valid option"
read x
fi
;;
esac
done

Screen Shot


Show recent files in Backtrack

No comments

Powered by Blogger.