0
1

.gitkeep ファイルを再帰的にセットする方法

Posted at

指定したフォルダ内の全てのディレクトリに .gitkeep ファイルを作成する方法

create_gitkeep.sh

#!/bin/bash

# 引数が指定されているかチェック
if [ -z "$1" ]; then
  echo "使用方法: $0 <ターゲットフォルダのパス>"
  exit 1
fi

# 引数として指定されたフォルダ
TARGET_DIR="$1"

# 再帰的にサブディレクトリに移動して .gitkeep ファイルを作成
find "$TARGET_DIR" -type d -exec sh -c 'cd "{}" && touch .gitkeep' \;

echo "再帰的に .gitkeep ファイルを作成しました。"

実行権限を付与

chmod 700 create_gitkeep.sh

実行

./create_gitkeep.sh /path/to/folder

これにより、指定したフォルダ内の全てのディレクトリに .gitkeep ファイルが作成されます。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1