"리눅스 두 파일 행 차집합"의 두 판 사이의 차이

34번째 줄: 34번째 줄:
</syntaxhighlight>
</syntaxhighlight>


==diff+grep+cut 사용==
==diff 사용==
{{소스헤더|A-B}}
{{소스헤더|A-B}}
<syntaxhighlight lang='console'>
<syntaxhighlight lang='console'>
root@wsl:~# diff -u a.txt b.txt | grep ^-[^-] | cut -c 2-
root@wsl:~# diff -u a.txt b.txt | grep ^- | sed 1d | cut -c 2-
11
11
33
33
44번째 줄: 44번째 줄:
{{소스헤더|B-A}}
{{소스헤더|B-A}}
<syntaxhighlight lang='console'>
<syntaxhighlight lang='console'>
root@wsl:~# diff -u b.txt a.txt | grep ^-[^-] | cut -c 2-
root@wsl:~# diff -u b.txt a.txt | grep ^- | sed 1d | cut -c 2-
66
66
</syntaxhighlight>
</syntaxhighlight>

2024년 2월 21일 (수) 16:14 판

1 개요

리눅스 파일 행 차집합
리눅스 파일 내용 차집합
A
root@wsl:~# cat a.txt
11
22
33
44
55
B
root@wsl:~# cat b.txt
22
44
66

2 comm 사용

A-B
root@wsl:~# comm -23 a.txt b.txt
11
33
55
B-A
root@wsl:~# comm -23 b.txt a.txt
66

3 diff 등 사용

A-B
root@wsl:~# diff -u a.txt b.txt | grep ^- | sed 1d | cut -c 2-
11
33
55
B-A
root@wsl:~# diff -u b.txt a.txt | grep ^- | sed 1d | cut -c 2-
66

4 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}