I have a bash script which reads a file extension and list files of that extension using 'find' command. After that it reads name of the file. Now after this how can I open that file using name and extension variables if the file is not present in the current directory. This is the script:
find . -type f -name "*.png"
find . -type f -name "*.jpg"
echo "Enter file extension"
read xt
find . -type f -name "*.$xt"
echo "Enter file name"
read fn
xdg-open $fn.$xt
First it lists PNG and jpg files. It'll again print one list after we enter file extension we desire. After that it reads name of file but if the file is not in current directory how it can open it?
find . -type f -name "$fn.$xt" -exec xdg-open {} \;
, but I am not sure what you're trying to accomplish with this script.