0

I have a script that takes as an argument a path to a file upon which it performs certain operations. These files are stored in directories with path storage///_id/files (so in 2016 July 22 it would be storage/2016/Jul/22_1/files for the first set of files, .../Jul/22_2/files for second one etc.). The problem is each directory stores files with two extensions (say file.doc, file.txt) and I want to perform operations only on .txt files. I've tested earlier something like

for file in "/home/gonczor/temp/"*/*".txt"; do
    echo "$file"
done

And it worked perfectly given that names in directories don't change. When I move one step further and add this 22_1, 22_2, 23_1 directories something strange happens. This is my script (simplified):

for file in "$FILE_PATH/""$YEAR/""$MONTH/""$DAY"*/*".txt"; do
    my_program ${report}
done

And instead of finding .../2016/Jul/22_1/file.txt it finds /2016/Jul/22*/*.txt

How can I make it work? The solution I've tried to make up is from here

Community
  • 1
  • 1
gonczor
  • 3,994
  • 1
  • 21
  • 46
  • 3
    Are you sure there is a match? Is `$FILE_PATH` defined? When bash doesn't match any files, it returns your string to you, and I suspect that is happening.... – gilez Jul 22 '16 at 15:08
  • Yep, that's what was wrong. I'm too late at work. Thanks. – gonczor Jul 22 '16 at 15:12

0 Answers0