ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

๋ฐ˜์‘ํ˜•

โœ… ๋ฆฌ๋ˆ…์Šค ํŒŒ์ผ๋น„๊ต cmp, diff

ํŒŒ์ผ ๋‚ด์šฉ

test1.txt test2.txt

cmp ๋ช…๋ น์–ด

#-b ๋น„๊ต์‹œ ํŒŒ์ผ๊ฐ„ ์ฒซ๋ฒˆ์งธ๋กœ ๋‹ค๋ฅธ ๋ฌธ์ž์˜ ๋ฐ”์ดํŠธ๋ฅผ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.
$cmp -b test1.txt test2.txt
test1.txt test2.txt differ: byte 5, line 2 is 124 T 164 t

# ํŒŒ์ผ์˜ ๋‘๋ฒˆ์งธ ๋ผ์ธ์„ ๋ณด๋ฉด ๋Œ€๋ฌธ์ž T์™€ ์†Œ๋ฌธ์ž t ๊ฐ€ ๋‹ค๋ฆ…๋‹ˆ๋‹ค.
# sTart | start

#-i 5๋ฐ”์ดํŠธ ๋’ค์˜ ์ฒซ๋ฒˆ์งธ ๋‹ค๋ฅธ ๋ฌธ์ž๋ฅผ ๋ฐ”์ดํŠธ๋กœ ์ถœ๋ ฅํ•ด์ค๋‹ˆ๋‹ค
$cmp -bi 5 test1.txt test2.txt
test1.txt test2.txt differ: byte 20, line 4 is 152 j 151 i

#-l ๋น„๊ต์‹œ ๋‹ค๋ฅธ๋ฌธ์ž์— ๋Œ€ํ•ด 8์ง„์ˆ˜๊ฐ’์œผ๋กœ ์ถœ๋ ฅ(์ฒซ๋ฒˆ์งธ๋Š” ๋ฐ”์ดํŠธ ๋‘๋ฒˆ์งธ ์„ธ๋ฒˆ์งธ๋Š” ์ฐจ์ด๋‚˜๋Š” ๋ฌธ์ž์˜ 8์ง„์ˆ˜๊ฐ’)
$cmp -l test1.txt test2.txt
 5 124 164
25 152 151
26 141 164
27 160 141
28 145 154
29 156 171
31 143 145
32 150 156
33 151 144

diff ๋ช…๋ น์–ด

์˜ต์…˜ ์„ค๋ช…
-b ์—ฐ์†๋œ ๊ณต๋ฐฑ ๋ฌด์‹œ
-i ๋Œ€์†Œ๋ฌธ์ž ๊ตฌ๋ถ„ํ•˜์ง€ ์•Š์Œ
-t ์ถœ๋ ฅ ๋ผ์ธ์— TAB๋ฌธ์ž๋ฅผ ๋„ฃ์Œ
-w ๋‘ ํ–‰์˜ ๋น„๊ต ์‹œ ๊ณต๋ฐฑ์„ ๋ฌด์‹œ
--brief ํŒŒ์ผ ๋น„๊ต ํ›„ ๊ฒฐ๊ณผ ํ‘œ์‹œ
-d ๋‘ ํŒŒ์ผ๊ฐ„์˜ ์ฐจ์ด์  ์ƒ์„ธ ์ถœ๋ ฅ
-H ํฐ ํŒŒ์ผ๋“ค ์ฒ˜๋ฆฌ์‹œ ์‚ฌ์šฉ
-q ๋‘ ํŒŒ์ผ์˜ ์ฐจ์ด์ ๋งŒ ์ถœ๋ ฅ
-s ๋‘ ํŒŒ์ผ์ด ๊ฐ™์„ ๋•Œ ์•Œ๋ฆผ
-r ๋‘ ๋””๋ ‰ํ† ๋ฆฌ์˜ ์ฐจ์ด์  ์ถœ๋ ฅ, ์„œ๋ธŒ๋””๋ ‰ํ† ๋ฆฌ๊นŒ์ง€ ๋น„๊ต
-u ๋‘ ํŒŒ์ผ์˜ ๋ณ€๊ฒฝ๋˜๋Š” ๋ถ€๋ถ„๊ณผ ๋ณ‘๊ฒฝ๋˜๋Š” ๋ถ€๋ถ„์˜ ๊ทผ์ฒ˜ ๋‚ด์šฉ๋„ ์ถœ๋ ฅ
-N New file๋„ ์ ์šฉ๊ฐ€๋Šฅ
$diff -u test1.txt test2.txt
--- test1.txt	2021-12-13 13:52:37.000000000 +0900
+++ test2.txt	2021-12-13 13:47:58.000000000 +0900
@@ -1,7 +1,6 @@
 hi
-sTart
+start
 korea
 american
-japen
-china
-eNd
\ No newline at end of file
+italy
+end
\ No newline at end of file

$diff -c test1.txt text2.txt
*** test1.txt	2021-12-13 13:52:37.000000000 +0900
--- test2.txt	2021-12-13 13:47:58.000000000 +0900
***************
*** 1,7 ****
  hi
! sTart
  korea
  american
! japen
! china
! eNd
\ No newline at end of file
--- 1,6 ----
  hi
! start
  korea
  american
! italy
! end
\ No newline at end of file

$diff -d test1.txt test2.txt
2c2
< sTart
---
> start
5,7c5,6
< japen
< china
< eNd
\ No newline at end of file
---
> italy
> end
\ No newline at end of file
๊ณต์ง€์‚ฌํ•ญ
์ตœ๊ทผ์— ์˜ฌ๋ผ์˜จ ๊ธ€
์ตœ๊ทผ์— ๋‹ฌ๋ฆฐ ๋Œ“๊ธ€
Total
Today
Yesterday
๋งํฌ
ยซ   2024/12   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
๊ธ€ ๋ณด๊ด€ํ•จ
๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ (80)
๐Ÿ“บ Develop (0)
๐ŸŒ‹ Error Fixed (5)
๐Ÿ— Tool (5)
๐Ÿ’ป MacBook M1 (15)
๐Ÿ“ฆ ETC (1)

์ด ํฌ์ŠคํŒ…์€ ์ฟ ํŒก ํŒŒํŠธ๋„ˆ์Šค ํ™œ๋™์˜ ์ผํ™˜์œผ๋กœ, ์ด์— ๋”ฐ๋ฅธ ์ผ์ •์•ก์˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ œ๊ณต๋ฐ›์Šต๋‹ˆ๋‹ค.