I have a little ugly bash script on my Ubuntu machine that contains the lines:
search_command="find -L $(printf "%q" "$search_folder") \( ! -regex '.*/\..*/..*' \) -mindepth 1 2> /dev/null"
for i in "${IGNOREENDINGS[@]}"
do
search_command="$search_command -not -name \"*$i\""
done
search_command="$search_command | sed 's|^${search_folder}/\?||'"
choice=$(eval "$search_command"|fzf -q "$file_query" -1 --preview "preview $search_folder {}")
The script lets me choose a file, using fzf
among the matches of a GNU find
command.
It has the following problem: Once I choose a file in the interface of fzf
the script closes the fzf interface, so that seems to be done, but then I still have to wait for the find
command to complete (verified with top
), which somehow takes very long. I'm not really sure why; the files that I want always appear almost instantly.
I included a few extra lines above to avoid an X Y problem. I am happy with anything with the same functionality and quicker execution.
find
? If you need all files, you need to wait for it. While the files you want may appear instantly, it still needs to look at every single file in the directory you have given it to know if there are any more matches. So if you need it to go through all the files, you have to wait for it. It might help if you explained what the script is trying to do since the code isn't very clear. – terdon Feb 02 '19 at 17:50