I am writing a bash script that, when launched from a directory, Breflects the directory structure of the directory Ain the directory B.
I am currently doing this:
dirify () {
echo $1
}
export -f dirify
find "../test" -type d -exec bash -c "dirify '{}'" \;
I run this script from a directory B, and ../testthis is a directory A. Fortunately, the directory that I use for testing contains folders with 'in the name. When I run this script, bash gives the following error when it reaches these directories:
> bash: -c: line 0: unexpected EOF while looking for matching `''
> bash: -c: line 1: syntax error: unexpected end of file
(note that line 0 and line 1 refer to lines inside the function dirify())
A more simplified way of illustrating this problem is as follows:
find "../test" -exec bash -c "echo '{}'" \;
This example shows the same errors.
, , , '.
, ?