operating system

arrays.pl

A UNIX Command
$cat arrays.pl
# Simple array constructs.
@fred = ("How", "are", "you", "today?");
print "\@fred contains (@fred).\n";

$mike = $fred[1];
print "$mike $fred[3]\n";

# The array name in a scalar context gives the size.
$fredsize = @fred;
print '@fred has ', "$fredsize elements.\n";

# The $#name gives the max subscript (size less one).
print "Max sub is $#fred\n";

$perl arrays.pl
@fred contains (How are you today?).
are today?
@fred has 4 elements.
Max sub is 3
$

UNIX Explanation
Variables whose names begin with @ are arrays. If @sue is
an array,  it is  different variable from  $sue. However,
members   of  @sue   are  selected   by   $sue[$i].   The
construction $#arrname gives the maximum subscript of the
array @arrname.

source : http://sandbox.mc.edu/~bennet/perl/leccode/var2_pl.html

bzip2, bunzip2 – a block-sorting file compressor, v1.0.4

Connected From This

A UNIX Command

$wget http://www.kernel.org/pub/linux/kernel/v3.0/patch-3.0.4.bz2
--2011-09-03 19:22:43--  http://www.kernel.org/pub/linux/kernel/v3.0/patch-3.0.4.bz2
Resolving www.kernel.org... 130.239.17.5, 149.20.4.69, 199.6.1.165, ...
Connecting to www.kernel.org|130.239.17.5|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 96120 (94K) [application/x-bzip2]
Saving to: `patch-3.0.4.bz2'

100%[===================================================================================>] 96,120      85.3K/s   in 1.1s

2011-09-03 19:22:45 (85.3 KB/s) - `patch-3.0.4.bz2' saved [96120/96120]

$bunzip2 patch-3.0.4.bz2
$ls patch-3.0.4
patch-3.0.4
$


UNIX Explanation

bzip2  compresses files  using the  Burrows-Wheeler block
sorting text  compression algorithm, and  Huffman coding.
Compression  is generally  considerably better  than that
achieved    by    more    conventional    LZ77/LZ78-based
compressors,  and approaches the  performance of  the PPM
family of statistical compressors.

Related Source Code Exposition


for (t = 0; t < nGroups; t++) {
minLen = 32;
maxLen = 0;
for (i = 0; i len[t][i] > maxLen) maxLen = s->len[t][i];
if (s->len[t][i] len[t][i];
}
BZ2_hbCreateDecodeTables (
&(s->limit[t][0]),
&(s->base[t][0]),
&(s->perm[t][0]),
&(s->len[t][0]),
minLen, maxLen, alphaSize
);
s->minLens[t] = minLen;
}

Source Code Highlight

Create the Huffman decoding tables

Featured Image

Related Knowledge

bzip2  expects a  list  of file  names  to accompany  the
command-line   flags.   Each  file   is  replaced   by  a
compressed   version    of   itself,   with    the   name
"original_name.bz2".  Each  compressed file has  the same
modification  date,   permissions,  and,  when  possible,
ownership  as the corresponding  original, so  that these
properties  can be  correctly  restored at  decompression
time.   File name  handling is  naive in  the  sense that
there is no mechanism for preserving original file names,
permissions,  ownerships or  dates  in filesystems  which
lack  these concepts,  or have  serious file  name length
restrictions, such as MS-DOS.

source : debian manual pages for bzip2

scalar.pl —-x strings

A UNIX Command
$perl scalar.pl
The variable $fred contains Fred here.
Sum is 66.
$cat scalar.pl
$fred = "Fred here";
$barney = 56;
$sum = 10 + $barney;
print 'The variable $fred' . " contains $fred.\n";
print "Sum is $sum.\n";

$cat scalar.pl
$fred = "Fred here";
$barney = 56;
$sum = 10 + $barney;
print 'The variable $fred.' . " contains $fred.\n";
print "Sum is $sum.\n";

$perl scalar.pl
The variable $fred. contains Fred here.
Sum is 66.
$cat scalar.pl
$fred = "Fred here";
$barney = 56;
$sum = 10 + $barney;
print "The variable $fred." . " contains $fred.\n";
print "Sum is $sum.\n";

$perl scalar.pl
The variable Fred here. contains Fred here.
Sum is 66.
$

UNIX Explanation
Various operations on scalar (string) variables.

source: http://sandbox.mc.edu/~bennet/perl/leccode/var1_pl.html

hello.pl —x Prints the message using two different delimeters.

A UNIX Command
$cat hello.pl
# Prints the message using two different delimeters.
print "Hello, world!\n";
print qq=Did you say "Hello?"\n=;

$perl hello.pl
Hello, world!
Did you say "Hello?"
$

UNIX Explanation
"print"  is  categorized  under  Input/Output Functions.
Prints the message using two different delimeters.

source : http://sandbox.mc.edu/~bennet/perl/leccode/index.html

history – shows command history

A UNIX Command
$history
   11  ls
   12  vi kernel_start.s
   13  as kernel_start.s
   14  ls -l
   15  sh a.out
   16  ls
   17  vi kernel_start.s
   18  ls
   19  cd linux/
   20  ls
   21  cd boot/
   22  ls
   23  as boot.s
   24  cd
   25  cd linux-2.6
   26  ls
   27  cd arch/
   28  ls
   29  cd ..
   30  find . -name *.s
   31  find . -name *.S
   32  find . -name *.S | less
   33  find . -name *.S | grep oo
   34  find . -name *.S | grep oo | grep 64
   35  qcd arch/x86/
   36  cd arch/x86/
   37  ls
   38  cd boot/
   39  ls
   40  cd compressed/
   41  ls
   42  vi head_64.S
   43  ls
   44  cd ..
   45  ls
   46  cd ..
   47  find . -name *.S | grep oo | less
   48  cd arch/x86/
   49  ls
   50  cd boot/
   51  ls
   52  cd tools/
   53  ls
   54  cd ...
   55  ls
   56  cd ..
   57  ls
   58  cd co
   59  cd compressed/
   60  ls
   61  vi head_64.S
   62  cd
   63  cd symmel/
   64  cd linux/
   65  ls
   66  cd kernel/
   67  ls
   68  cd ..
   69  ls
   70  cd boot/
   71  ls
   72  vi head.s
   73  vi boot.s
   74  ls
   75  cd ..
   76  ls
   77  make
   78  cd /sbin/
   79  cd
   80  whereis as
   81  cd /usr/bin/
   82  ln -s as gas
   83  sudo ln -s as gas
   84  gas
   85  cd
   86  cd symmel/
   87  ls
   88  cd linux/
   89  ls
   90  make
   91  ls
   92  cd boot/
   93  ls
   94  vi boot.s
   95  ls
   96  vi head.s
   97  ls
   98  grep -r setup *
   99  cd ..
  100  ls
  101  grep -r setup *
  102  export PS1=$
  103  grep -r setup *
  104  ls
  105  cd boot/
  106  ls
  107  vi head.s
  108  ls
  109  ps x
  110  ls -l
  111  ls
  112  cd
  113  emacs -nw rr
  114  cv
  115  cd
  116  emacs -nw rr
  117  pwd
  118  ls
  119  cat /proc/sys/net/ipv4/tcp_retries1
  120  export PS1=$
  121  cat /proc/sys/net/ipv4/tcp_retries1
  122  echo 4 > /proc/sys/net/ipv4/tcp_retries1
  123  cd
  124  cd linux-2.6
  125  ls
  126  cd Documentation/
  127  s
  128  ls
  129  cd net
  130  cd networking/
  131  ls
  132  vi ip-sysctl.txt
  133  ls
  134  cd ..
  135  ls
  136  pwd
  137  cd ..
  138  cd net/
  139  ls
  140  cd ip4
  141  cd ipv4/
  142  ls
  143  ls -l
  144  ls
  145  cd netfilter
  146  ls
  147  cd ..
  148  ls
  149  cd ..
  150  ls
  151  cd ipv4/
  152  ls
  153  grep -r retries *
  154  vi tcp_timer.c
  155  vi sysctl_net_ipv4.c
  156  vi tcp_timer.c
  157  ls
  158  pwd
  159  ls
  160  grep -r retries *
  161  vi tcp_timer.c
  162  man youtube-dl
  163  youtube-dl -f 22 http://www.youtube.com/watch?v=2nBND6TBY9Q
  164  cd
  165  emacs -nw dd
  166  pwd
  167  cd symmel/
  168  ls
  169  cd linux/
  170  ls
  171  cd boot/
  172  ls
  173  vi head.s
  174  cd sy
  175  cd symmel/
  176  ls
  177  cd linux/
  178  ls
  179  cd boot/
  180  ls
  181  vi boot.s
  182  vi head.s
  183  cd
  184  git clone  git@github.com:ahiliation/symmel.git
  185  rm -r symmel/
  186  rm -rf symmel/
  187  git clone  git@github.com:ahiliation/symmel.git
  188  cd symmel/
  189  ls
  190  vi kernel_start.asm
  191  ls
  192  ps x
  193  cd symmel/
  194  ls
  195  ls -l
  196  cat README
  197  ls
  198  rm a.out
  199  ls
  200  vi kernel_start.s
  201  ls
  202  cd
  203  git clone
  204  ls
  205  cd Downloads/
  206  rm *.torrent
  207  emacs -nw ee
  208  cd Downloads/Lab/
  209  ls
  210  ls -l
  211  file lab1handout\ \(1\)
  212  tar -xvvzf lab1handout\ \(1\)
  213  tar -xvvf lab1handout\ \(1\)
  214  ls
  215  rm lab1handout\ \(1\)
  216  ls
  217  cd lab1/
  218  ls
  219  vi CODING
  220  ls
  221  vi grade.sh
  222  sh grade.sh
  223  ls
  224  make
  225  ls
  226  cd boot/
  227  ls
  228  vi main.c
  229  ls
  230  vi sign.pl
  231  ls
  232  man -l main.c
  233  vi main.c
  234  ls
  235  vi boot.S
  236  ls
  237  cd ..
  238  ls
  239  cd kern/
  240  ls
  241  vi kernel.ld
  242  ls
  243  ls -l
  244  ls
  245  cd ..
  246  ls
  247  /usr/lib/freebsd/gmake
  248  ls
  249  make
  250  ls
  251  cd kern/
  252  ls
  253  vi entry.S
  254  cd
  255  apt-cache search bochs
  256  export PS1=$
  257  apt-cache search bochs
  258  sudo apt-get install bochs
  259  ls
  260  pwd
  261  bochs
  262  sql
  263  mysql
  264  mysql_client_test
  265  mysql_client_test --help
  266  cd
  267  ls
  268  ps x
  269  l s-l
  270  cd /
  271  ls
  272  cd /etc/init.d/
  273  ls
  274  ls -l
  275  ls
  276  cat README
  277  cat README | more
  278  ls
  279  cd
  280  ls
  281  export PS1=$
  282  ls
  283  pwd
  284  ls
  285  zslalal
  286  zzininfo
  287  zininfo
  288  zipinfo
  289  cd LatestBooks/
  290  ls
  291  ls -l
  292  du -h
  293  ls
  294  pwd
  295  cd ..
  296  cd Downloads/
  297  cd
  298  ls
  299  find . -name entry.S
  300  cd ..
  301  find . -name entry.S
  302  pwd
  303  cd
  304  cd Downloads/
  305  find . -name entry.S
  306  cd
  307  cd linux-2.6
  308  ls
  309  cd arch/
  310  ls
  311  cd x86/
  312  ls
  313  cd boot/
  314  ls
  315  cd ..
  316  pws
  317  ls
  318  find . -name entry.S
  319  pwd
  320  cd ..
  321  find . -name entry.S
  322  cd ..
  323  pwd
  324  find . -name entry.S
  325  cd arch/ia64/kernel/
  326  ls
  327  vi entry.S
  328  ls
  329  pwd
  330  cd Downloads/
  331  cd Lab/
  332  cd lab1/
  333  ls
  334  cd kern/
  335  ls
  336  vi entry.S
  337  ls
  338  cd ..
  339  ls
  340  cd boot/
  341  ls
  342  vi boot.S
  343  pwd
  344  ls
  345  ls -l
  346  cd Videos/
  347  ls
  348  ls -l
  349  ls
  350  mpg123 OruPonnu.MP3
  351  totem bluray.m4v
  352  ls
  353  totem 8WtQ-XQS_do.mp4
  354  totem clCQw0M7XfY.mp4
  355  ls
  356  totem 0ipk3kL_soU.mp4
  357  cd
  358  ls
  359  cd Downloads/
  360  cd Lab/
  361  ls
  362  cd lab1/
  363  ls
  364  cd boot/
  365  ls
  366  cd ..
  367  ls
  368  cd kern/
  369  ls
  370  vi entry.S
  371  ls
  372  cd
  373  cd symmel/
  374  ls
  375  vi loader.s
  376  ls
  377  mkdir loader
  378  ls
  379  mv loader.s loader
  380  ls
  381  git add loader/
  382  git commit loader/ -m "loader code from osdev.org"
  383  git push -u origin master
  384  mkdir Docs
  385  cd Docs/
  386  ls
  387  wget http://database.sarang.net/study/linux/asm/linux-asm.txt
  388  ls
  389  cd ..
  390  ls
  391  git add Docs/
  392  git commit Docs/ -m "linux assembler tutorial"
  393  git push -u origin master
  394  cd
  395  emacs -nw www
  396  man skill
  397  apt-file find /usr/bin/skill
  398  man skill
  399  skill
  400  export PS1=$
  401  skill
  402  skill -l
  403  ps aux | grep xine
  404  skill 2844
  405  ps aux | grep xine
  406  xine &
  407  ps aux | grep xine
  408  skill -t 1
  409  top
  410  '
  411  ls
  412  less
  413  ls | less
  414  page
  415  top
  416  ps | grep less
  417  ps | grep ls
  418  ps | grep xine
  419  ps
  420  ps aux | grep xine
  421  skill 2742
  422  ps aux | grep xine
  423  xine &
  424  skill
  425  ps aux | grep xine
  426  skill
  427  skill -t pty1
  428  skill -t pty
  429  skill -t 1
  430  ;s
  431  ls *.mp3
  432  mpg123 01*A
  433  mpg123 01*a
  434  mpg123 01*A.mp3
  435  mpg123 01*
  436  mpg123 01*A*
  437  df -h
  438  wget ftp://ftp.freebsd.org/pub/FreeBSD/snapshots/201011/FreeBSD-9.0-CURRENT-201011-i386-disc1.iso
  439  rm FreeBSD-9.0-CURRENT-201011-i386-disc1.iso
  440  b w s k stack
  441  bw tcp/ip stack symmel
  442  b c a m
  443  man join-dctrl
  444  ls
  445  buffer
  446  man buffer
  447  ls
  448  emacs -nw rr
  449  ls
  450  cd Downloads/
  451  cd NewTheme/
  452  ls
  453  cd LeanBizTheme/
  454  ls
  455  cd Theme/
  456  ls
  457  scp LeanBiz.zip jeffrin@192.168.0.101:/home/jeffrin
  458  scp LeanBiz.zip jeffrin@192.168.0.102:/home/jeffrin
  459  ls *.png
  460  pwd
  461  cd Downloads/
  462  cd
  463  ls
  464  ls *.png
  465  mv kirishnadas.jpg krishnadas.jpg
  466  pwd
  467  wget http://www.beautifulwork.org/symmel/aboutus.html
  468  vi aboutus.html
  469  export PS1=$
  470  emacs -nw ee
  471  export PS1=$
  472  virtuoso-t
  473  man virtuoso-t
  474  skill  virtuoso-t
  475  top
  476  htop
  477  vdir
  478  man vdir
  479  vdir Downloads/
  480  vdir symmel/
  481  ls symmel/
  482  man vdir
  483  chrt
  484  chrt -p 2377
  485  chrt -i -p 2377
  486  chrt -i  0 -p 2377
  487  man chrt
  488  chrt 0 ls
  489  chrt  ls
  490  man chrt
  491  chrt -p 0 1
  492  man chrt
  493  chrt 0 ls
  494  chrt -p 1
  495  chrt -p 1 -f
  496  chrt -p 2733  -f
  497  chrt -p 2377  -f
  498  chrt -p 2377
  499  htop
  500  man chrt
  501  ctstat
  502  man ctstat
  503  lnstat
  504  ctstat
  505  ctstat --help
  506  ctstat -c 10
  507  history
  508  export PS1=$
  509  history | less
  510  history
$

UNIX Explanation
The  history command performs  one of  several operations
related  to  recently-executed  commands  recorded  in  a
history list. Each of these recorded commands is referred
to  as an  ``event''.  When specifying  an  event to  the
history command, the following forms may be used:

[1] A  number: if positive,  it refers to the  event with
that number  (all events are numbered starting  at 1). If
the number  is negative, it selects an  event relative to
the current event (-1 refers to the previous event, -2 to
the one  before that, and so  on). Event 0  refers to the
current  event.


[2] A string: selects  the most recent event that matches
the string.  An event is  considered to match  the string
either if the string is  the same as the first characters
of the event,  or if the string matches  the event in the
sense of the string match command.