Bash script and following symlinks

i found a script for searching my eBooks collection using rofi. I have been using it for months now. today I moved my eBooks directory and made a symlink to the original place. now the script is not working like before. If i use the new absolute path instead of the symlinked path, the script works. I think the problem is with following the symlink. I very little about bash scripting. i have searched for solving this but couldn’t find any solution. Can anyone help me to fix it and at the same learn something new about shell scripting.
Thanks in advance. :blush:

Why do you want to make a symlink ? Just change the path at line 21 to the new path:


Yeah, the find command only looks for regular files so you could change that so it looks for symlinks as well:

readarray -t F_ARRAY <<< "$(find "$BOOKS_DIR" \( -type l -o -type f \) \( -iname \*.pdf -o -iname \*.epub -o -iname \*.mobi -o -iname \*.azw3 -o -iname \*.azw2 \))"


1 Like

I already did this. I just wanted to know what is causing the issue and learn a new thing. so that i can troubleshoot similar issue in the future :smile:

thanks for replying. :slight_smile: tried your solution, it does not work. :slight_smile:
as you pointed out the issue is with the find command, I duck & went a bit and tried this

readarray -t F_ARRAY <<< "$(find -L "$BOOKS_DIR" -type f \( -iname \*.pdf -o -iname \*.epub -o -iname \*.mobi -o -iname \*.azw3 -o -iname \*.azw2 \))"

which solved the issue.
Thanks a lot for pointing me to the right direction. :pray:t3: :slight_smile:

Glad you solved it with Head_on_a_Stick put you on tracks

1 Like