So I need to create a lot of text files.
Each of the text file is named AAAAA.txt, BBBBB.txt, CCCCC.txt and etc etc. Within each text file, all the content is as follows:
1.Copy “to-be-replaced”.txt into the folder EXCLUSIVE.
2.Copy the gs file to replace the existing gs file.
3.The .projectdata should also be copied to the correct path.
So, I need to write a script, that copies the name of the file (AAAAA, BBBBB, and so on) and then place it in the “to-be-replaced” within its content.
How can I do that? need some idea please.
Thank you~~ MT32
Advertisement
Answer
Use a HERE document which expands variables if the delimiter isn’t quoted:
#!/bin/bash for char in {A..Z} ; do filename=$char$char$char$char$char.txt cat <<EOF > $filename 1.Copy $filename into the folder EXCLUSIVE. 2.Copy the gs file to replace the existing gs file. 3.The .projectdata should also be copied to the correct path. EOF done