0

Im trying to find a file with x type and store that in a variable. It is working fine when i try to execute manually. If i try the same in a bash script it is displaying test_count='1 because of this "if" condition is failing.

Please find the code below :- `

usage_backup_dir=/test/usage_backup
DT_FILENAME=$(date +%Y%m%d); 
export DT_FILENAME
test_count=$(find $usage_backup_dir -type f -name "Summary_$DT_FILENAME*.bdm_all_cases.lg.log" -exec cat {} + )
echo $test_count`
KIA
  • 100
  • 9
MSR
  • 5
  • 3

1 Answers1

0

This command looks weird:

find $usage_backup_dir -type f -name "Summary_$DT_FILENAME*.bdm_all_cases.lg.log" -exec cat {} + 

I would end it as follows:

find $usage_backup_dir -type f -name "Summary_$DT_FILENAME*.bdm_all_cases.lg.log" -exec cat {} \;

(I've replaced + by \;)

I know there's some discussion about this ending (backslash or not, semicolon or not) but I'd advise you to have a look there.

Dominique
  • 16,450
  • 15
  • 56
  • 112