Skip to content

Instantly share code, notes, and snippets.

@sftblw
Created July 22, 2024 02:54
Show Gist options
  • Save sftblw/b213a9b4150eb4acf94b5e5fc209e23b to your computer and use it in GitHub Desktop.
Save sftblw/b213a9b4150eb4acf94b5e5fc209e23b to your computer and use it in GitHub Desktop.
compare_tree.sh (ChatGPT)
#!/bin/bash
# 비교할 폴더 경로를 인자로 받음
FOLDER1=/path_1
FOLDER2=/path_2
# 임시 파일 생성
TEMP1=$(mktemp)
TEMP2=$(mktemp)
# 첫 번째 폴더의 파일 목록 생성, 베이스 경로 제거
find "$FOLDER1" -type f | sed "s|^$FOLDER1/||" | sort > "$TEMP1"
# 두 번째 폴더의 파일 목록 생성, 베이스 경로 제거
find "$FOLDER2" -type f | sed "s|^$FOLDER2/||" | sort > "$TEMP2"
# 두 폴더의 파일 목록 비교
diff "$TEMP1" "$TEMP2"
# 임시 파일 삭제
rm "$TEMP1" "$TEMP2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment