Errors and Exceptions

commandline session $gcc error.c $cat error.c #include main() { int a=0; int b=10; printf(“Hello Alln”); printf(“%d”,b/a); } $./a.out > outputa Floating point exception $cat outputa $ $./a.out 2> outputa Hello All Floating point exception $./a.out > outputa Floating point exception $./a.out 2> outputb Hello All Floating point exception $./a.out &> outputc Floating point exception $cat …

pattern matching operators PART 1

commandline session $cat pm.sh #!/bin/bash filename=${1##*/} echo $filename $sh pm.sh /bin/bash bash $vim pm.sh $cat pm.sh #!/bin/bash filename=${1} echo $filename $sh pm.sh /bin/bash /bin/bash $vim pm.sh $cat pm.sh #!/bin/bash filename=${#} echo $filename $sh pm.sh /bin/bash 1 $vim pm.sh $cat pm.sh #!/bin/bash filename=${##} echo $filename $sh pm.sh /bin/bash 1 $vim pm.sh $cat pm.sh #!/bin/bash filename=${*} echo …

SOURCING .

commandline session $cat var Name=Jeffrin Age=36 $echo $Name $. var $echo $Name Jeffrin $echo $Age 36 $./var bash: ./var: Permission denied $chmod 744 var $./var $echo $Age 36 $bash $echo $Name $./var $echo $Name $. var $echo $Name Jeffrin $ls -l var -rwxr–r– 1 jeffrin jeffrin 20 Apr 10 00:41 var $

some useful /proc parameters

commandline session root>cat /proc/sys/fs/file-max 198152 root>cat /proc/sys/net/ipv4/ip_forward 0 root>cat /proc/sys/dev/cdrom/autoeject 0 root>cat /proc/sys/dev/scsi/logging_level 0 root>cat /proc/sys/kernel/hostname debian root>cat /proc/sys/kernel/osrelease 3.2.0-4-amd64 root>cat /proc/sys/net/core/rmem_max 131071 root>cat /proc/sys/vm/laptop_mode 0 root>cat /proc/sys/vm/swappiness 60 root>

help Get Help for Shell Builtins

commandline session $help source source: source filename [arguments] Execute commands from a file in the current shell. Read and execute commands from FILENAME in the current shell. The entries in $PATH are used to find the directory containing FILENAME. If any ARGUMENTS are supplied, they become the positional parameters when FILENAME is executed. Exit Status: …

TYPE COMMAND Indicate how a command name is interpreted

commandline session $type ls ls is aliased to `ls –color=auto’ $type cp cp is /bin/cp $type mv mv is /bin/mv $type happy bash: type: happy: not found $type gnome-session gnome-session is /usr/bin/gnome-session $type rm rm is /bin/rm $type rm -r rm is /bin/rm bash: type: -r: not found $type ‘rm -r’ bash: type: rm -r: …

nl [ -i ] line number increment at each line

commandline session $cat comma.pl use strict; use warnings; for (qw/ 179550 45960 890458 -12345678 1000000000000/) { (my $n = $_) =~ s/(d+?)(?=(d{3})+b)/$1,/g; print “$nn”; } $nl comma.pl 1 use strict; 2 use warnings; 3 for (qw/ 179550 45960 890458 -12345678 1000000000000/) { 4 (my $n = $_) =~ s/(d+?)(?=(d{3})+b)/$1,/g; 5 print “$nn”; 6 } $nl …

PERL @ (at sign) and ARRAY

commandline session $cat array.pl #!/usr/bin/perl use strict; use warnings; my @colors = (“red”,”green”,”blue”); print “@colors”; print “n”; $perl array.pl red green blue $vim array.pl $cat array.pl #!/usr/bin/perl use strict; use warnings; my @colors = (“red”,”green”,”blue”); print “@colors”; print “n”; print $color[0]; print “n”; $perl array.pl Global symbol “@color” requires explicit package name at array.pl line …

Perl TESTING for gcc compiler option related

commandline session $cat testgcc.pl #!/usr/bin/perl -w use Test::More tests => 2 ; my $result; system “gcc unsigned.c”; $result = `./a.out`; #print $result; ok ($result lt 0); system “gcc -funsigned-char unsigned.c”; $result = `./a.out`; #print $result; ok ($result gt 0); $cat unsigned.c #include int main(void) { char c = -10; printf(“%d”,c); return 0; } $perl testgcc.pl …