Created
July 22, 2024 02:54
-
-
Save sftblw/b213a9b4150eb4acf94b5e5fc209e23b to your computer and use it in GitHub Desktop.
compare_tree.sh (ChatGPT)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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