Skip to main content

Find not working as expected with space in directory [Resolved]

I have a script calling this

find "/mnt/Data/Shared/$1" -type d -exec bash -c 'fixperm "'${1}'" "fd" "$0"' {} \;

$1 is a directory, when the name contains no spaces it works, when there is a space its fails an returns errors. Testing with "00_Office Test"

Test" "fd" "$0": -c: line 0: unexpected EOF while looking for matching `"'
Test" "fd" "$0": -c: line 1: syntax error: unexpected end of file

I thought it may be because the path was missing the \ before the space but that does not fix the issue. I'm sure I'm missing something trivial here.

Question Credit: SBTech
Question Reference
Asked July 18, 2019
Posted Under: Unix Linux
2 Answers

Your Answer