What is the difference:

d=$(date +%Y%m%d) f=$(ls -l /nmt/user/out/csv1$d.csv_*_response) echo $f 

If you execute commands from the terminal, then everything works; if you execute from a script, then
displays /mnt/user/out/csv120160326.csv_*_response , i.e. * taken as it is.
How to fix?

  • one
    Do you have an interpreter in a shell? same as in the script? There is a confusion with escaping characters in zsh , I have at least. Therefore, I do not want to move from bash to zsh :) - approximatenumber

1 answer 1

I have something from the terminal that with the help of the script displays /mnt/user/out/csv120160326.csv__response

What kind of speech?

Maybe you mean f=$(ls -l /nmt/user/out/csv1${d}.csv__response) ?

Update

Then maybe so?

 #!/bin/bash d=$(date +%Y%m%d) echo `ls -l /nmt/user/out/csv1${d}.csv_*_response` 
  • There are files that dynamically create a piece between * . Those. for example, csv20160326.csv_237452389476235_response. When searching for a piece instead, I substitute * but nothing comes out. - Volodimir