is there a way to do a search of a user's current working directory for all files beginning with backup_file
and then storing all the data within those files as a variable?
Asked
Active
Viewed 187 times
0

Nigel Wash
- 107
- 7
-
Does this answer your question? [How do I set a variable to the output of a command in Bash?](https://stackoverflow.com/questions/4651437/how-do-i-set-a-variable-to-the-output-of-a-command-in-bash) – Kind Stranger May 06 '21 at 12:50
-
@Kind Stranger Not really. I understand how to store data from files into a variable. However, I have no clue how to store all files starting with a match (e.g. backup_file) into one variable. – Nigel Wash May 06 '21 at 13:11
1 Answers
2
Something like this? cat
will fetch the contents of given file(s). .
is current directory.
all_data="$(cat ./backup_file*)"

Kind Stranger
- 1,736
- 13
- 18