I am new to bash shell scripting, apologies if this was already asked.
I have combinations of multiple files such as:
USA.txt Florida.txt Miami.txt
I would like to join those files and create a new file which contains everything such as:
cat *.txt > USA_FLORIDA_MIAMI.txt
In another case The thing is that some other time the files have a different prefix:
Canada.txt Quebec.txt Montreal.txt
so in this second case, the output will be CANADA_QUEBEC_MONTREAL.txt:
cat *.txt > CANADA_QUEBEC_MONTREAL.txt
and so on for all the combinations of other files
In the first case scenario, USA.txt Florida.txt Miami.txt are the only .txt files present in the directory. In the second case, they will be replaced by Canada.txt Quebec.txt Montreal.txt so I would need to write a code which all the time combines the information of the prefix of all the .txt files present at that time in the directory and it adds it to the prefix of the output file. The variable here is the name of the Country, State and City.
Any suggestion about any command which I could use? thanks