반응형
선행 공백을 무시하면서 2 개의 파일을 어떻게 비교할 수 있습니까?
2 개의 소스 파일이 있는데 동일한 버전이 다릅니다. 그러나 하나는 들여 쓰기를 변경 한 다른 편집기를 통해 이루어 졌으므로 모든 행이 diff에서 다르게 표시됩니다.
출력이 선행 공백 / 탭을 무시한 후 다른 줄만 표시되도록 비교하는 데 사용할 수있는 diff 명령 또는 필터가 있습니까?
diff
유용 할 수있는 몇 가지 옵션이 있습니다.
-E, --ignore-tab-expansion
ignore changes due to tab expansion
-Z, --ignore-trailing-space
ignore white space at line end
-b, --ignore-space-change
ignore changes in the amount of white space
-w, --ignore-all-space
ignore all white space
-B, --ignore-blank-lines
ignore changes whose lines are all blank
따라서 diff -w old new
모든 공백을 무시하고 실질적으로 다른 행만보고해야합니다.
탭을 잘못 사용하는 경우 수정할 수 있습니다.
expand bad_file
diff -bB file[12]
-b, --ignore-space-change
ignore changes in the amount of white space
-B, --ignore-blank-lines
ignore changes whose lines are all blank
그주의 -w
선 같은 옵션이 diffing의 전에 모든 공백을 무시하는 것 this i s a line
과 this is a line
같이 비교 각 파일 thisisaline
과 차이점을보고하지 않습니다.
-w
옵션 문제 외에도 옵션에도 -b
사소한 문제가 있으며 줄을 구걸 할 때 공백을 무시하지 않습니다.
따라서 sed
처음에 발생한 공백을 제거 하기 위해 를 사용해야 하고`diff -bB를 수행해야합니다.
diff -bB <(sed 's/^[ \t]*//' file1) <(sed 's/^[ \t]*//' file2)
반응형
'Development Tip' 카테고리의 다른 글
날짜 시간 x 시리즈에 대한 엑셀 플롯 (0) | 2020.12.12 |
---|---|
플라스크에서 ajax에서 게시 된 데이터를 어떻게 사용할 수 있습니까? (0) | 2020.12.12 |
pytz 요구 사항을 충족하는 버전을 찾을 수 없습니다. (0) | 2020.12.12 |
편집기 창 분할 바로 가기는 무엇입니까? (0) | 2020.12.12 |
Java 컴파일러가 연결할 수없는 then 문에 대해 연결할 수없는 문 오류를 생성하지 않는 이유는 무엇입니까? (0) | 2020.12.12 |