0

Problem.

directory=mac/1.x.x/** 

even though mac/1.x.x/**/*.sql is right path,

cat ${directory}/*.sql 

the command above said No such file or directory . and I want to make that possible.

What I tried.

to check the path is right, I did cat mac/1.x.x/**/*.sql. and it worked

Does having ${} interrupt cat command's path reading or something?

mhutter
  • 2,800
  • 22
  • 30
  • did you enabled `shopt -s globstar` – Jetchisel Apr 16 '20 at 00:51
  • are you running script from the same directory as you do it in shell? you can try to use full directory path starting from root cat /home/user/${directory}/*.sql – Saboteur Apr 16 '20 at 00:51
  • 3
    Welcome! It would be a good idea to `echo "$directory"` to know to what it is expanding after all. And give the error code verbatim. – Quasímodo Apr 16 '20 at 01:07
  • I would for such tests even do a `set -x` instead of `echo`, to always see what's going on. Also, to make sure that your variable `directory` has not some hidden characters in it, which might spoil everything, I would dump its content using `xxd <<<$directory`, and not `echo $directory`. – user1934428 Apr 16 '20 at 06:45
  • You have a directory named literally `**`? – KamilCuk Apr 16 '20 at 07:45
  • `above said No such file or directory` Please post the whole error message. – KamilCuk Apr 16 '20 at 07:55

0 Answers0