1

Problem:

I have an escaped string saved within a variable:

escapedFileName='/dbDumps/Mon\ Oct\ \ 1\ 15\:22\:50\ UTC\ 2018.sql'

but whenever I try to use this file name within the following command, I get an error message saying that this path does not exist (even though it does).

/usr/bin/mysql -u root -pmypassword system < "$escapedFileName";

When i use the path and not the string it works :

/usr/bin/mysql -u root -pmypassword system < /dbDumps/Mon\ Oct\ \ 1\ 15\:22\:50\ UTC\ 2018.sql

What am I doing wrong ?

Chris Davies
  • 116,213
  • 16
  • 160
  • 287
Lukas
  • 13

1 Answers1

1

You don't need to escape when you put the text between quotes.

Therefore remove the \s

escapedFileName='/dbDumps/Mon Oct  1 15:22:50 UTC 2018.sql'

And you should not escape the :, they don't need it, and it will break it.