BASH: 如何使用脚本复制文件名并将其插入到文本中?
BASH: How to copy the name of the file and insert it into the text using script?
所以我需要创建很多文本文件。
每个文本文件被命名为 AAAAA.txt、BBBBB.txt、CCCCC.txt 等等。
在每个文本文件中,所有内容如下:
1.Copy "to-be-replaced".txt 进入 EXCLUSIVE 文件夹。
2.Copy 替换现有 gs 文件的 gs 文件。
3.The .projectdata 也应该复制到正确的路径。
所以,我需要编写一个脚本,复制文件名(AAAAA、BBBBB 等),然后将其放在 "to-be-replaced" 的内容中。
我该怎么做?请需要一些想法。
谢谢~~
MT32
如果未引用定界符,请使用扩展变量的 HERE 文档:
#!/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
所以我需要创建很多文本文件。
每个文本文件被命名为 AAAAA.txt、BBBBB.txt、CCCCC.txt 等等。 在每个文本文件中,所有内容如下:
1.Copy "to-be-replaced".txt 进入 EXCLUSIVE 文件夹。
2.Copy 替换现有 gs 文件的 gs 文件。
3.The .projectdata 也应该复制到正确的路径。
所以,我需要编写一个脚本,复制文件名(AAAAA、BBBBB 等),然后将其放在 "to-be-replaced" 的内容中。
我该怎么做?请需要一些想法。
谢谢~~ MT32
如果未引用定界符,请使用扩展变量的 HERE 文档:
#!/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