How to find the path

Hi

Iam new to this forum,

could you pleae advise for below question

iam send path as input before proceding i need to validate the path if it is exit or not if not it show path id not exist

if the path is exits iam sending file name as input to search the file on the paricular path if the path is not avaible it show file is not found

could you please give some cmds

What Have you tried..

could you share your codes...?

Thanks
Sha

i have tryed below

its going fine but i need to validation

#!/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"

Hi

I tried the above one but its not working when iam validateing the path it will check only one time after second time it not validateing the path

Hi ,

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"

Thanks
Sha