How to use sed to simulate grep -v?
Answer:
There are two methods to simulate grep -v (print out line(s) if not match) in sed.
# sed -n '/regexp/!p'
or
# sed '/regexp/d'
How to use sed to simulate grep -v?
Answer:
There are two methods to simulate grep -v (print out line(s) if not match) in sed.
# sed -n '/regexp/!p'
or
# sed '/regexp/d'
Array reference in Perl
Answer:
Array reference is something like a pointer to a array data structure in Perl
Example:
use strict;
use warnings;
my @a = (1, 2, 3);
my $array_ref = \@a;
$a[2] = "foo";
print $array_ref->[2]; # print out "foo" as change in @a will also be reflected in its reference
How to kill a TCP connection using tcpkill?
Answer:
You can use the tcpkill program.
tcpkill came with the dsniff in Debian/Ubuntu, you need to install it manually.
# sudo apt-get install dsniff
Usages:
1. Kill all outgoing web (port 80) connection:
# tcpkill -i eth0 port 80
2. Kill all connection by IP
# tcpkill -i eth0 host www.google.com
Hash reference in Perl
Answer:
Hash reference is something like a pointer to a hash data structure in Perl
Example:
my %hash = (
"a" => "1",
"b" => "2",
);
my $hash_ref = \%hash;
$hash{"a"} = "A";
print $hash_ref->{"a"}; # print out "A" as change in %hash also reflected in its reference
Replace string in MySQL
Answer:
Replace a string with the UPDATE statement is easy in MySQL
E.g.
mysql> UPDATE table1 SET name = REPLACE (name, 'foo', 'bar');