I have a bash script called
findme, which is coded as follows:
#!/bin/bash locate -Abi '*\.'$1 $2 | grep --color=always -ni $2 | less -R
It searches for me for all files with a specified file extension (first argument provided to the script) which has a pattern (the next provided argument) in its filename.
If I execute the following:
user@machine$ findme pdf classifi
It will search for all
classifi in its filename. So I may get something like the following result.
The question is: "Can you give me a bash script code in which after showing the results ask me for a number and a viewer, to automate my next job?"
for example I would like, if I enter:
> 2 evince
the script executes
evince on the
2nd item of the search result, i.e.,
if this is what I entered on the previous search result it executes: