13.07.2015 Views

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 11 ■ TRACKING DOWN BUGS01 7c702 < 127.0.0.1 localhost03 ---04 > 127.0.0.1 localhost localhost.localdomain05 10a11,1206 >07 > 192.168.0.23 ldapserverLines 01–04 show the first change, and lines 05–07 show the second change. 7c7 means that in thisfirst change line 7 is being compared with line 7. In the first file (/etc/hosts) named on the commandline, line 7 is as shown in line 02 of the diff output (marked with ). Line 03 marks the division between thetwo files. (If multiple lines in a block were altered, you’d get more than one line at line 02 and line 04,and the dividing mark would be more useful.) So, in hosts-client1, 127.0.0.1 is also defined aslocalhost.localdomain, rather than just localhost.The second set of changes means that at line 10 the second file also adds lines 11 and 12. Lines 06and 07 of the diff output show those two added lines: an entry for the LDAP server.Another form of output is to use the -C option, which gives you a certain number of lines of contextfor each change. (Unfortunately, this isn’t compatible with the -y; option, which is described in a coupleof paragraphs.)> diff -C 1 /etc/hosts hosts-client1*** /etc/hosts 2009-02-02 21:45:58.000000000 +1300--- hosts-client1 2009-06-03 09:58:50.000000000 +1200****************** 6,8 ****##! 127.0.0.1 localhost255.255.255.255 broadcasthost--- 6,8 ----##! 127.0.0.1 localhost localhost.localdomain255.255.255.255 broadcasthost****************** 10 ****--- 10,12 ----fe80::1%lo0 localhost++ 192.168.0.23 ldapserverAs you can see, this form of output gives you a bit more information about the file and can be a littlemore readable than the default output. -C 1 gives you one line of context on each side of the change,with the change marked with ! for changed lines and + for added lines (- for removed lines, although thisis not shown here). You can specify as much context as you like; or -c gives a default three lines ofcontext.You can also use diff -y to show the files in two columns: the changes in the second file will bemarked with | for changes and > for added lines. If you do this, it’ll be easier to read if you also use the --suppress-common-lines option:diff -y --suppress-common-lines /etc/hosts hosts-client1217Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!