Skip to content

Instantly share code, notes, and snippets.

@caryyu
Last active March 5, 2020 02:39
Show Gist options
  • Save caryyu/cca1a66d9679fde760437071678903b7 to your computer and use it in GitHub Desktop.
Save caryyu/cca1a66d9679fde760437071678903b7 to your computer and use it in GitHub Desktop.
把某个目录下的所有文件及内容拷贝至 Java 的 Properties 文件格式中

比如某个目录 /secret 有如下文件:

📦/secret
┣ 📜AGE - 20
┗ 📜NAME - 李三


path=$1
path=${path:="/secret"}

for f in $path/*;
do
  echo "${f##*/} = `cat $f`" >> /tmp/secrets.properties
done

cp /tmp/secrets.properties $path

输出的属性文件 /tmp/secrets.properties 内容如下:

NAME = 李三
AGE = 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment