Ihe atụ iwu Linux sdiff maka Linux Newbies


N'ime otu edemede anyị gara aga, anyị akọwala ihe gbasara 9 kacha mma ntụnyere faịlụ na ihe dị iche (Diff) maka sistemụ Linux. Anyị depụtara ngwakọta nke ahịrị iwu yana ngwa GUI maka atụnyere na ịchọta ọdịiche dị n'etiti faịlụ, nke ọ bụla nwere njiri mara ụfọdụ. A na-akpọ uru diff ọzọ bara uru maka Linux sdiff.

sdiff bụ ngwa ahịrị iwu dị mfe maka igosi ọdịiche dị n'etiti faịlụ abụọ na ijikọ ọnụ. Ọ dị mfe iji wee bịa na nhọrọ ojiji kwụ ọtọ dịka akọwara n'okpuru.

Okwu syntax maka iji sdiff bụ nke a.

$ sdiff option... file1 file2

Gosi ọdịiche dị n'etiti faịlụ abụọ na Linux

1. Ụzọ kachasị mfe iji na-agba ọsọ sdiff bụ ịnye aha faịlụ abụọ ị na-agbalị iji tụnyere. Ọ ga-egosi ọdịiche jikọtara ọnụ n'akụkụ dịka egosiri na nseta ihuenyo na-esonụ.

$ cal >cal.txt
$ df -h >du.txt
$ sdiff du.txt cal.txt

Mekwaa faịlụ niile ka faịlụ ederede

2. Iji na-emeso faịlụ niile dị ka ederede ma tụnyere ha n'ahịrị n'ahịrị, ma ọ bụ faịlụ ederede ma ọ bụ na ọ bụghị, jiri ọkọlọtọ -a.

$ sdiff -a du.txt cal.txt

Filesystem      Size  Used Avail Use% Mounted on	      |	     April 2018       
udev            3.9G     0  3.9G   0% /dev		      |	Su Mo Tu We Th Fr Sa  
tmpfs           788M  9.7M  779M   2% /run		      |	 1  2  3  4  5  6  7  
/dev/sda10      324G  265G   43G  87% /			      |	 8  9 10 11 12 13 14  
tmpfs           3.9G  274M  3.6G   7% /dev/shm		      |	15 16 17 18 19 20 21  
tmpfs           5.0M  4.0K  5.0M   1% /run/lock		      |	22 23 24 25 26 27 28  
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup	      |	29 30                 
/dev/loop2       82M   82M     0 100% /snap/core/4206	      |	                      
/dev/loop4      181M  181M     0 100% /snap/vlc/190	      <
/dev/loop1       87M   87M     0 100% /snap/core/4407	      <
/dev/loop0      189M  189M     0 100% /snap/vlc/158	      <
/dev/loop3       83M   83M     0 100% /snap/core/4327	      <
cgmfs           100K     0  100K   0% /run/cgmanager/fs	      <
tmpfs           788M   40K  788M   1% /run/user/1000	      <

Ileghara Taabụ na Oghere Ọcha

3. Ọ bụrụ na ị nwere faịlụ nwere nnukwu oghere ọcha, ị nwere ike ịgwa sdiff ka ọ na-eleghara oghere ọcha niile anya mgbe ị na-atụnyere iji mgba ọkụ -W.

$ sdiff -W du.txt cal.txt

4. Ị nwekwara ike ịgwa sdiff ka ọ na-eleghara oghere ọcha ọ bụla na njedebe ahịrị site na iji -z nhọrọ.

$ sdiff -z du.txt cal.txt

5. Na mgbakwunye, ị nwere ike ịkụziri sdiff ka ọ leghara mgbanwe anya n'ihi mgbasawanye taabụ na ọkọlọtọ -E.

$ sdiff -E du.txt cal.txt

Ileghara ikpe ka ị na-atụnyere ọdịiche

6. Ka ileghara ikpe (ebe sdiff na-ewere nnukwu na obere obere ka otu), jiri nhọrọ -i dị ka egosiri.

$ sdiff -i du.txt cal.txt

Ileghara ahịrị oghere ka ị na-atụnyere ọdịiche

7. Nhọrọ -B na-enyere aka ileghara ahịrị oghere na faịlụ.

$ sdiff -B du.txt cal.txt

Kọwaa ọnụọgụ nke kọlụm ị ga-ewepụta

8. sdiff na-enye gị ohere ịtọ nọmba nke kọlụm ndị a ga-ebipụta (default is 130), site na iji -w ịgbanwee dị ka ndị a.

$ sdiff -w 150 du.txt cal.txt

Gbasaa taabụ na oghere

9. Iji gbasaa taabụ gaa na oghere dị na mmepụta, jiri nhọrọ -t.

$ sdiff -t du.txt cal.txt

Gbaa sdiff Interactively

10. Ọkọlọtọ -o na-enyere ya aka ịmekọrịta mmekọrịta yana zipu mmepụta na faịlụ. Na iwu a, a ga-eziga mmepụta na faịlụ sdiff.txt, pịa Tinye mgbe ị hụchara akara % , iji nweta menu mmekọrịta.

$ sdiff du.txt cal.txt -o sdiff.txt

Filesystem      Size  Used Avail Use% Mounted on	      |	     April 2018       
udev            3.9G     0  3.9G   0% /dev		      |	Su Mo Tu We Th Fr Sa  
tmpfs           788M  9.7M  779M   2% /run		      |	 1  2  3  4  5  6  7  
/dev/sda10      324G  265G   43G  87% /			      |	 8  9 10 11 12 13 14  
tmpfs           3.9G  274M  3.6G   7% /dev/shm		      |	15 16 17 18 19 20 21  
tmpfs           5.0M  4.0K  5.0M   1% /run/lock		      |	22 23 24 25 26 27 28  
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup	      |	29 30                 
/dev/loop2       82M   82M     0 100% /snap/core/4206	      |	                      
/dev/loop4      181M  181M     0 100% /snap/vlc/190	      <
/dev/loop1       87M   87M     0 100% /snap/core/4407	      <
/dev/loop0      189M  189M     0 100% /snap/vlc/158	      <
/dev/loop3       83M   83M     0 100% /snap/core/4327	      <
cgmfs           100K     0  100K   0% /run/cgmanager/fs	      <
tmpfs           788M   40K  788M   1% /run/user/1000	      <
% 
ed:	Edit then use both versions, each decorated with a header.
eb:	Edit then use both versions.
el or e1:	Edit then use the left version.
er or e2:	Edit then use the right version.
e:	Discard both versions then edit a new one.
l or 1:	Use the left version.
r or 2:	Use the right version.
s:	Silently include common lines.
v:	Verbosely include common lines.
q:	Quit.
%

Rịba ama na ị ga-enwerịrị ụfọdụ ndị ndezi dịka ed etinyere na sistemụ gị tupu i jiri ha, na nke a.

Kpọọ mmemme ọzọ iji tụnyere faịlụ

11. Mgbanwe --diff-program na-enye gị ohere ịkpọ ngwá ọrụ iwu-ahịrị ọzọ, karịa sdiff n'onwe ya iji tụnyere faịlụ, dịka ọmụmaatụ, ịnwere ike ịkpọ mmemme diff dị ka egosiri.

$ sdiff --diff-program=diff du.txt cal.txt

Maka ozi ndị ọzọ, gaa na ibe sdiff man.

$ man sdiff

N'ime edemede a, anyị lere anya n'ihe atụ ngwaọrụ akara iwu sdiff maka ndị mbido. Ọ bụrụ na ị nwere ajụjụ ọ bụla, jiri ụdị nkọwa n'okpuru iru anyị.