Diff Command Examples
diff command compares two different files and reports the difference.
The output is very cryptic and not straight forward to read.
Syntax:
#diff [options] file1 file2
option :
-w in the diff command will ignore the white space while performing the comparison.
[root@desktop17 ~]# cat abc1
network cloud
kr network cloud
hello
[root@desktop17 ~]# cat abc2
network cloud
hi
kr network cloud
hello
[root@desktop17 ~]# diff abc1 abc2
1a2
> hi
[root@desktop17 ~]#
Duplicate File Changes Patch
Diff and Patch command:-
* diff output stored in a file is called a "patchfile"
use -u for "unified" diff, best in patchfiles
* patch duplicates changes in other files (user with care!)
use -b to automatically backup changed files.
[root@desktop17 ~]# cat abc1
network cloud
hi
kr network cloud
hello
[root@desktop17 ~]#cp abc1 abc2
[root@desktop17 ~]# cat abc2
network cloud
hi
kr network cloud
hello
[root@desktop17 ~]# vim abc2
edit some thing new.
:wq
[root@desktop17 ~]# diff -u abc1 abc2
--- abc1 2013-06-14 15:28:46.845938983 +0530
+++ abc2 2013-06-14 15:28:33.439937131 +0530
@@ -1,4 +1,3 @@
network cloud
-hi
network cloud
hello
[root@desktop17 ~]# diff -u abc1 abc2 > /tmp/abc.patch
[root@desktop17 ~]#
[root@desktop17 ~]#
[root@desktop17 ~]# patch -b abc1 /tmp/abc.patch
patching file abc1
[root@desktop17 ~]# cat abc1
network cloud
hi
kr network cloud
hello
Means Confirm thathave been applied by running diff again.
You should see no output, indicating that the files are now identical.
Display total connect time of users
Ac command will display the statistics about the user’s connect time.Connect time for the current logged in user
With the option –d, it will break down the output for the individual
days. In this example, I’ve been logged in to the system for more than 6
hours today. On Dec 1st, I was logged in for about 1 hour.
# ac –d
Dec 1 total 1.08
Dec 2 total 0.99
Dec 3 total 3.39
Dec 4 total 4.50
Today total 6.10
Connect time for all the users
To display connect time for all the users use –p as shown below.
Please note that this indicates the cumulative connect time for the
individual users.
# ac -p
harry 3.64
madison 0.06
sanjay 88.17
nitesh 105.92
rakesh 111.42
total 309.21
Connect time for a specific user
To get a connect time report for a specific user, execute the following:
# ac -d nitesh
Jul 2 total 12.85
Aug 25 total 5.05
Sep 3 total 1.03
Sep 4 total 5.37
Dec 24 total 8.15
Dec 29 total 1.42
Today total 2.95
i am indeed very proud to be a student of kr network cloud...........this session is very interesting for self study.........
ReplyDeleteThank you for such a wonderful Information !!
ReplyDeleteHere is a list of Top LINUX INTERVIEW QUESTIONS
Linux FTP vsftpd Interview Questions
SSH Interview Questions
Apache Interview Questions
Nagios Interview questions
IPTABLES Interview Questions
Ldap Server Interview Questions
LVM Interview questions
Sendmail Server Interview Questions
YUM Interview Questions
NFS Interview Questions
Read More at :- Linux Troubleshooting
it is very good article and very useful for Linux learners we also provide Linux Online Training for more info Click here
ReplyDeleteYou have written wonderful article. Greetings and thank youLINUX training in noida
ReplyDeleteit's very good and useful
ReplyDeleteNice blog post!!! Very informative and appreciable . keep going on. I really read it.
ReplyDeleteBest sap institute in India ,SAP online training & sap training courses
SAP ABAP on HANA Online Training
sap hana online training
sap S/4 HANA training online
SAP UI5 Online Training in India
Learn SAP online
sap fiori training online
sap fico training online
Thanks
I am glad to find amazing information from the blog. Thanks for sharing the information..and more information Please go trough the link : Linux training in Hyderabad
ReplyDeleteSSarika
ReplyDeleteIt is Good informative blog. Nice blog. Thanks for the who is posted the good information thanks.
DevOps Training in Hyderabad
Thanks for sharing such a great blog Keep posting..
ReplyDeleteLinux Training in Delhi
Linux Training institute in Delhi