this adds “0 0 0 0 0 example.sh” to your crontab:
1 |
cat <(crontab -l) <(echo "0 0 0 0 0 example.sh") | crontab - |
If you want to limit your bandwidth in Linux you could use trickle or wondershaper, to limit a process use this:
1 |
trickle -u 100 -d 500 wget http://example.com |
trickle -u[up] -d [down] [program]
for a global limit use:
1 |
wondershaper eth0 500 100 |
wondershaper [interface] [down] [up]
for remove :
wondershaper clear [interface]
Test String (10xX):
1 |
___XXXXX_____XXXXX_____ |
Test Cases Results must look like:
single char remove:
1 |
___XXXX_____XXXXX_____ |
single char replace:
1 |
___0XXXX_____XXXXX_____ |
string/multi char remove:
1 |
_____________ |
string/multi char replace:
1 |
___00000_____00000_____ |
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:
1 |
time cat bench.txt | sed 's/X//' |
single char replace:
1 |
time cat bench.txt | sed 's/X/0/' |
multi char remove:
1 |
time cat bench.txt | sed 's/X//g' |
multi char replace:
1 |
time cat bench.txt | sed 's/X/0/g' |
string remove:
1 |
time cat bench.txt | sed 's/XXXXX//g' |
string replace:
1 |
time cat bench.txt | sed 's/XXXXX/00000/g' |
AWK 4.0.1
single replace with regex not possible.
multi char remove:
1 |
time cat bench.txt | awk '{gsub("X","",$1);print $1;}' |
multi char replace:
1 |
time cat bench.txt | awk '{gsub("X","0",$1);print $1;}' |
string remove:
1 |
time cat bench.txt | awk '{gsub("XXXXX","",$1);print $1;}' |
string replace:
1 |
time cat bench.txt | awk '{gsub("XXXXX","00000",$1);print $1;}' |
TR 8.21
single replace and remove not possible.
multi char replace:
1 |
time cat bench.txt | tr "X" "0" |
string replace:
1 |
time cat bench.txt | tr "XXXXX" "00000" |
PERL REGEX 5
single char remove:
1 |
time cat bench.txt | perl -lpe 's/X//' |
single char replace:
1 |
time cat bench.txt | perl -lpe 's/X/0/' |
multi char remove:
1 |
time cat bench.txt | perl -lpe 's/X//g' |
multi char replace:
1 |
time cat bench.txt | perl -lpe 's/X/0/g' |
string remove:
1 |
time cat bench.txt | perl -lpe 's/XXXXX//g' |
string replace:
1 |
time cat bench.txt | perl -lpe 's/XXXXX/00000/g' |
PERL TR 5
multi char replace:
1 |
time cat bench.txt | perl -lpe 's/X/0/g' |
string replace:
1 |
time cat bench.txt | perl -lpe 's/XXXXX/00000/g' |
For creating a ram disk in Linux use this:
1 2 |
mkdir /media/myramdisk mount -t ramfs ramfs /media/myramdisk |
its not possible to set a size, so watch out of your system memory!
to ad a alias in Linux, edit this config:
1 |
nano /etc/bash.bashrc |
as example:
1 |
home='cd ~' |
to reload the config use:
1 |
bash |
To get some infos about your GNU/Linux OS run this:
1 |
lsb_release -a |
Result looks like:
1 2 3 4 5 |
No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 7.8 (wheezy) Release: 7.8 Codename: wheezy |