![]() |
![]() |
4 Einträge, 1 Seite |
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
xtest11 # cat test.txt
/home: /home:
/home/re17830: /home/re17830:
159 .Xauthority | 106 .Xauthority
9734 .sh_history.1 | 7425 .sh_history.1
116 .sh_history.2 | 93 .sh_history.2
/home/re17830/.ssh: /home/re17830/.ssh:
/home/re17830/chksize: /home/re17830/chksize:
1613 build_checksize_db.ksh | 1600 build_checksize_db.ksh
2183 checksize | 2151 checksize
0 test.txt <
/home/re17830/chksize/checksize_db: /home/re17830/chksize/checksize_db:
1076213 SizeCheck-08-01-15.dat | 97882 SizeCheck-08-01-15.dat
1080180 SizeCheck-08-01-16.dat <
/home/re17830/scripts: /home/re17830/scripts:
/home/root: /home/root:
6927 .bash_history | 6910 .bash_history
8402 .sh_history.1 | 2130 .sh_history.1
13310 .sh_history.2 | 13304 .sh_history.2
305 .vi_history | 327 .vi_history
/home/root/.ssh: /home/root/.ssh:
3296 known_hosts | 3068 known_hosts
/home/root/scripts: /home/root/scripts:
/home/webadmin: /home/webadmin:
/home/webadmin/.ssh: /home/webadmin/.ssh:
>
xtest11 #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
xtest11 # perl rework.pl
/home
/home/re17830
.Xauthority 159 106 Diff: 53
.sh_history.1 9734 7425 Diff: 2309
.sh_history.2 116 93 Diff: 23
/home/re17830/.ssh
/home/re17830/chksize
build_checksize_db.ksh 1613 1600 Diff: 13
checksize 2183 2151 Diff: 32
/home/re17830/chksize/checksize_db
SizeCheck-08-01-15.dat 1076213 97882 Diff: 978331
/home/re17830/scripts
/home/root
.bash_history 6927 6910 Diff: 17
.sh_history.1 8402 2130 Diff: 6272
.sh_history.2 13310 13304 Diff: 6
.vi_history 305 327 Diff: 22
/home/root/.ssh
known_hosts 3296 3068 Diff: 228
/home/root/scripts
/home/webadmin
/home/webadmin/.ssh
xtest11 #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
xtest11 # perl rework.pl
/home/re17830
.Xauthority 159 106 Diff: 53
.sh_history.1 9734 7425 Diff: 2309
.sh_history.2 116 93 Diff: 23
/home/re17830/chksize
build_checksize_db.ksh 1613 1600 Diff: 13
checksize 2183 2151 Diff: 32
/home/re17830/chksize/checksize_db
SizeCheck-08-01-15.dat 1076213 97882 Diff: 978331
/home/root
.bash_history 6927 6910 Diff: 17
.sh_history.1 8402 2130 Diff: 6272
.sh_history.2 13310 13304 Diff: 6
.vi_history 305 327 Diff: 22
/home/root/.ssh
known_hosts 3296 3068 Diff: 228
xtest11 #
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
32
33
34
35
#!/usr/bin/perl
use warnings;
use strict;
sub calcdiff {
my $old = shift;
my $new = shift;
if ($new > $old) {
my $ergebniss_1 = ($new - $old);
return($ergebniss_1);
} elsif ($old > $new) {
my $ergebniss_2 = ($old - $new);
return ($ergebniss_2);
}
}
open(INFILE, "test.txt");
my @content = <INFILE>;
foreach (@content) {
if (my $path = $_ =~ m/^(.+):\s+(\/.+):$/) {
chomp($path);
print("$1\n");
} elsif (my $size = $_ =~ m/(^\d+)\s+(.+)\s+(.)\s+(\d+)\s+(.+)\s+$/) {
chomp($size);
if ($3 eq "\|") {
print "\t$2\t$1\t$4\t" . "Diff: " . &calcdiff("$1","$4") . "\n";
} elsif ($3 eq "\<") {
print("\tNew File:\t$5\tSize: $4\n");
} elsif ($3 eq "\>") {
print("\tFile deleted:\t$5\n");
}
}
}
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 32 33 34 35 36 37 38 39 40 41 42 43
#!/usr/bin/perl use warnings; use strict; sub calcdiff { my $old = shift; my $new = shift; if ($new > $old) { my $ergebniss_1 = ($new - $old); return($ergebniss_1); } elsif ($old > $new) { my $ergebniss_2 = ($old - $new); return ($ergebniss_2); } } my @order; open(INFILE, "test.txt"); while( my $line = <INFILE> ){ if ( $line =~ m/^(.+):\s+\/.+:$/) { push @order, [$1."\n"]; } elsif ( $line =~ m/(^\d+)\s+(.+)\s+(.)\s+(\d+)\s+(.+)\s+$/ ) { if ($3 eq "\|") { push @{ $order[-1] },"\t$2\t$1\t$4\t" . "Diff: " . &calcdiff("$1","$4") . "\n"; } elsif ($3 eq "\<") { push @{ $order[-1] }, "\tNew File:\t$5\tSize: $4\n"; } elsif ($3 eq "\>") { push @{ $order[-1] },"\tFile deleted:\t$5\n"; } } } for( @order ){ next if @$_ == 1; print $_ for @$_; }
1
2
3
27: if ($3 eq "\|") {
28: push @{ $order[-1] },"\t$2\t$1\t$4\tDiff: " . abs($1 - $4) . "\n";
29: }
![]() |
![]() |
4 Einträge, 1 Seite |