0 Members and 1 Guest are viewing this topic.
Start-Date: 2015-01-12 17:11:15Commandline: apt-get dist-upgradeStart-Date: 2015-01-14 16:58:30Commandline: apt-get dist-upgrade
Start-Date: 2015-01-12 17:11:15 Commandline: apt-get dist-upgradeStart-Date: 2015-01-14 16:58:30 Commandline: apt-get dist-upgrade
egrep '(Start-Date:.*|Commandline: apt-get )' /var/log/apt/history.log | sed '$!N;s/\n/ /'
Start-Date: 2015-01-22 18:11:10End-Date: 2015-01-22 18:11:11Start-Date: 2015-01-22 18:11:33End-Date: 2015-01-22 18:11:33
perl -0ne 's/\RCommandline/ Commandline/g; print;' /var/log/apt/history.log | grep Commandline
perl -ne 'chomp;print$l=(/^Com/)?"$l$_\n":"";$l="$_ "' /var/log/apt/history.log
#!/usr/bin/perl# concatenate all lines beginning with "Commandline" with the previous line use strict; use warnings; # -w switch{ while (<>) { # The -n switch reads filename arguments or STDIN chomp; # remove trailing newline if (/^Commandline/) { # actual record does begin with "Commandline" print "$last$_\n" # append previous record with actual record } else { # not yet found a Commandline! print "" # so print nothing in this case (avoid grep) } $last = "$_ " # remember actual record until next loop }}
perl -wlne 'print "$last $_" if (/^Command/); $last=$_' /var/log/apt/history.logoderperl -wlne '/^Command/ && print "$last $_"; $last=$_' /var/log/apt/history.log
awk '/^Command/ { print last " " $0;} { last=$0; }' /var/log/apt/history.log
sed '/^Com/!{h;d};/^Com/{x;G;s/\n/ /}' </var/log/apt/history.log
while read line; do [[ $line =~ Commandline ]] && printf "%s %s\n" "$last" "$line"; last="$line"; done < /var/log/apt/history.log