#!/bin/bash
echo -e "please enter the file name to search..... \n"
read file_keyword
echo "pleae enter the path where we can search the file...... \n"
read path
echo "searched files are..... \n"
find "$path" -name "*${file_keyword}*" -exec ls -l {} \; | tr -s " " | cut -d" " -f6,7,9
echo -e "please select file name from with the path from above file list \n"
I have included small validation part for path...
hope this should return message .."Please Enter correct Path now..."
incase path is not a valid one...
#!/bin/bash
echo -e "please enter the file name to search..... \n"
read file_keyword
echo "pleae enter the path where we can search the file...... \n"
read path
cd $path > /dev/null
if [ $? -ne 0 ]
then
echo "Please Enter correct Path now..."
fi
read path
echo "searched files are..... \n"
find "$path" -name "*${file_keyword}*" -exec ls -l {} \; | tr -s " " | cut -d" " -f6,7,9
echo -e "please select file name from with the path from above file list \n"
let say you have script called script.sh inside which you have written below codes..then..
..
inside if condition i have added some codes to validate again and again till you give correct path...
Hope this helps you...
#scriptname script.sh
#!/bin/bash
echo -e "please enter the file name to search..... \n"
read file_keyword
echo "pleae enter the path where we can search the file...... \n"
read path
cd $path > /dev/null
if [ $? -ne 0 ]
then
echo -e "\n\n\t Please enter correct path to proceed further....\n\n\t"
bash script.sh
fi
read path
echo "searched files are..... \n"
find "$path" -name "*${file_keyword}*" -exec ls -l {} \; | tr -s " " | cut -d" " -f6,7,9
echo -e "please select file name from with the path from above file list \n"