GNU/Linux

In this article I wrote about the Linux-Kernel and the GNU-Project, together they are called GNU/Linux.It is an Unix like Operating system and in the most cases POSIX-compliant and open source.The Kernel was firs released in the year 1991 from Linus Torvalds.

 

GNU/Linux is often used for Servers, there are a lot of open source software for work, a very powerful Shell and you have always Perl on the System.And the System needs not as much resources as Microsoft Systems.

 

I regularly use Debian or Mint,Debian is more stable, more for Servers and you could make a minimal installation with or without an GUI.Mint is more for Desktop users with a good looking Desktop.

 

For more take a look in the GNU/Linux Bash – Category

Perl array vs. hash handing over Benchmark

I want to compare the hash and array in Perl and both of them with a reference and a normal handing over.That is the code, I tried to hold it as simple and fast as possible:

Our result :

Looks good, the keys from the hashes are not sorted but I don’t want to waste performance with a sort.

 

Now this is the Benchmark result from 1..4 :

We could see the normal array is faster than the shift and prototype so for small data a reference is not faster than a normal use, but by the hash it is much faster than a normal handing over.and we could see array is faster than a hash, but the hash takes more information (key and values).

 

And this is the Benchmark result from 1..1000 :

Now the reference from the array and hash are both fastest, the hash is always slower than the array.Just take a look at scalars.

Bash rename files

This is an example how to rename files with regex.

At first we need to create some files:

Lets look what we got:

now rename this files:

And we see the renamed files:

Benchmark Bash fastest replace with tr sed awk perl

Test String (10xX):

Test Cases Results must look like:

single char remove:

single char replace:

string/multi char remove:

string/multi char replace:

Times:

run the test string from file 100000 times.

single char remove single char replace multi char remove multi char replace string remove string replace
sed 5.658s 5.774s 3.449s 5.929s 3.476s 5.724s
perl regex 5.604s 5.918s 3.428s 6.027s 3.482s 5.870s
awk gsub 3.469s 5.892s 3.339s 5.942s
tr bash 5.972s 5.897s
perl tr  5.996s  5.837s

 

For bash its the easiest way to use sed because its simpler to use perl and it could do the most things or if you do simple things you could use tr.In perl you could see this benchmark.

SED 4.2.2

single char remove:

single char replace:

multi char remove:

multi char replace:

string remove:

string replace:

 

AWK 4.0.1

single replace with regex not possible.

multi char remove:

multi char replace:

string remove:

string replace:

 

TR 8.21

single replace and remove not possible.

multi char replace:

string replace:

 

PERL REGEX 5

single char remove:

single char replace:

multi char remove:

multi char replace:

string remove:

string replace:

 

PERL TR 5

multi char replace:

string replace:

 

Get IP´s

To get the adapters wit IPs use this:

Result: