I want to cat all files to one new file in a bash script.For example there are three files in my dir:- file_a.txt- file b.txt- file(c).txtWhen I write the following, it works without problems:cat file*.txt >> out_file.bakNo I want to make it more flexible/clean by using a variable:input_files=file*.txtcat $input_files >> out_file.bakUnfortunately this doesn't work. The question is why? (When I echo input_files and run the command in terminal everything is fine. So why doesn't it work in the bash script?)
Use asterisk in variables
bash;shell script;ksh;variable;escape characters
It depends when you want to do the expansion:When you define the variable:$ files=$(echo a*)$ echo $filesa1 a2 a3$ echo $filesa1 a2 a3When you access the variable:$ files=a*$ echo $filesa*$ echo $filesa1 a2 a3