Skip to content
Advertisement

Find command in linux bash shell

the find command is:

JavaScript

I want to convert to:

JavaScript

so my code (is doesn’t work):

JavaScript

Advertisement

Answer

What you are attempting cannot be solved in the general case with “classic sh” because you need your script to work correctly with directories named * or '"[ ]"', and plain old flat strings simply don’t allow that to be properly quoted (easily, or even with a fair amount of complexity). Fortunately, as suggested in a comment, Bash arrays allow you to do this with all the necessary level of control. Just make sure to always use quotes around anything which could contain a file name.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement