Monthly Archives: April 2012

grep . bracket expressions [ ]

commandline session

$ 4.2.20 14 514---> grep '[bg]zip' worked
$ 4.2.20 15 515---> grep '[bg]sort' worked
$ 4.2.20 16 516---> grep '[b ]sort' worked
Bubble sort
Selection sort
Insertion sort
Shell sort
Comb sort
Merge sort
Counting sort
 Bucket sort
 Radix sort
 Distribution sort
$ 4.2.20 17 517---> grep '[b  ]sort' worked
Bubble sort
Selection sort
Insertion sort
Shell sort
Comb sort
Merge sort
Counting sort
 Bucket sort
 Radix sort
 Distribution sort
$ 4.2.20 18 518---> cat worked
Bubble sort
Selection sort
Insertion sort
Shell sort
Comb sort
Merge sort
Heapsort
Quicksort
Counting sort
 Bucket sort
 Radix sort
 Distribution sort
 Timsort
$ 4.2.20 19 519--->

grep . dot meta character

commandline session

$ 4.2.20 37 537---> grep  rt  worked
Bubble sort
Selection sort
Insertion sort
Shell sort
Comb sort
Merge sort
Heapsort
Quicksort
Counting sort
 Bucket sort
 Radix sort
 Distribution sort
 Timsort
$ 4.2.20 38 538---> grep  p.rt  worked
$ 4.2.20 39 539---> grep  ..rt  worked
Bubble sort
Selection sort
Insertion sort
Shell sort
Comb sort
Merge sort
Heapsort
Quicksort
Counting sort
 Bucket sort
 Radix sort
 Distribution sort
 Timsort
$ 4.2.20 40 540---> grep  s.rt  worked
Bubble sort
Selection sort
Insertion sort
Shell sort
Comb sort
Merge sort
Heapsort
Quicksort
Counting sort
 Bucket sort
 Radix sort
 Distribution sort
 Timsort
$ 4.2.20 41 541--->

grep . global regular expression print . (name of file)

commandline session

$ 4.2.20 15 515---> grep -L ar /usr/sbin/*
/usr/sbin/add-shell
/usr/sbin/cracklib-format
/usr/sbin/remove-shell
/usr/sbin/su-to-root
/usr/sbin/tzconfig
/usr/sbin/update-grub
/usr/sbin/update-grub2
/usr/sbin/update-icon-caches
/usr/sbin/update-icon-caches.gtk2
$ 4.2.20 16 516--->


$ 4.2.20 12 512---> ls /usr/sbin/ | grep -l ar
(standard input)
$ 4.2.20 13 513---> grep -l ar /usr/sbin/
$ 4.2.20 14 514---> grep -l ar /usr/sbin/*
/usr/sbin/a2dismod
/usr/sbin/a2dissite
/usr/sbin/a2enmod
/usr/sbin/a2ensite
/usr/sbin/accept
/usr/sbin/accessdb
/usr/sbin/acpid
/usr/sbin/addgroup
/usr/sbin/adduser
/usr/sbin/alsa
/usr/sbin/alsactl
/usr/sbin/anacron
/usr/sbin/apache2
/usr/sbin/apache2ctl
/usr/sbin/apachectl
/usr/sbin/arp
/usr/sbin/arpd
/usr/sbin/aspell-autobuildhash
/usr/sbin/avahi-daemon
/usr/sbin/bccmd
/usr/sbin/biosdecode
/usr/sbin/bluetoothd
/usr/sbin/cf-agent
/usr/sbin/cf-execd
/usr/sbin/cf-key
/usr/sbin/cf-know
/usr/sbin/cf-monitord
/usr/sbin/cf-promises
/usr/sbin/cf-report
/usr/sbin/cf-runagent
/usr/sbin/cf-serverd
/usr/sbin/chat
/usr/sbin/check_forensic
/usr/sbin/checkgid
/usr/sbin/cherryd
/usr/sbin/chgpasswd
/usr/sbin/chpasswd
/usr/sbin/chroot
/usr/sbin/ck-log-system-restart
/usr/sbin/ck-log-system-start
/usr/sbin/ck-log-system-stop
/usr/sbin/console-kit-daemon
/usr/sbin/cpgr
/usr/sbin/cppw
/usr/sbin/cracklib-check
/usr/sbin/cracklib-packer
/usr/sbin/cracklib-unpacker
/usr/sbin/create-cracklib-dict
/usr/sbin/cron
/usr/sbin/cryptdisks_start
/usr/sbin/cryptdisks_stop
/usr/sbin/cryptmount-setup
/usr/sbin/cupsaccept
/usr/sbin/cupsaddsmb
/usr/sbin/cupsctl
/usr/sbin/cupsdisable
/usr/sbin/cupsenable
/usr/sbin/cupsreject
/usr/sbin/cytune
/usr/sbin/debootstrap
/usr/sbin/defoma-reconfigure
/usr/sbin/delgroup
/usr/sbin/deluser
/usr/sbin/dkms
/usr/sbin/dmidecode
/usr/sbin/dnsmasq
/usr/sbin/dpkg-divert
/usr/sbin/dpkg-preconfigure
/usr/sbin/dpkg-reconfigure
/usr/sbin/dpkg-statoverride
/usr/sbin/e2freefrag
/usr/sbin/e4defrag
/usr/sbin/exicyclog
/usr/sbin/exigrep
/usr/sbin/exim
/usr/sbin/exim4
/usr/sbin/exim_checkaccess
/usr/sbin/exim_convert4r4
/usr/sbin/exim_dbmbuild
/usr/sbin/exim_dumpdb
/usr/sbin/exim_fixdb
/usr/sbin/exim_lock
/usr/sbin/eximstats
/usr/sbin/exim_tidydb
/usr/sbin/exinext
/usr/sbin/exipick
/usr/sbin/exiqgrep
/usr/sbin/exiqsumm
/usr/sbin/exiwhat
/usr/sbin/famd
/usr/sbin/fatresize
/usr/sbin/fdformat
/usr/sbin/filefrag
/usr/sbin/gconf-schemas
/usr/sbin/gdm3
/usr/sbin/gnome-menus-blacklist
/usr/sbin/gpm
/usr/sbin/gpm-microtouch-setup
/usr/sbin/gpm-mouse-test
/usr/sbin/groupadd
/usr/sbin/groupdel
/usr/sbin/groupmod
/usr/sbin/grpck
/usr/sbin/grpconv
/usr/sbin/grpunconv
/usr/sbin/grub-install
/usr/sbin/grub-mkconfig
/usr/sbin/grub-mkdevicemap
/usr/sbin/grub-mknetdir
/usr/sbin/grub-probe
/usr/sbin/grub-reboot
/usr/sbin/grub-set-default
/usr/sbin/grub-setup
/usr/sbin/hald
/usr/sbin/hciattach
/usr/sbin/hciconfig
/usr/sbin/hciemu
/usr/sbin/hcitrace
/usr/sbin/htcacheclean
/usr/sbin/httxt2dbm
/usr/sbin/iconvconfig
/usr/sbin/install-docs
/usr/sbin/install-info
/usr/sbin/install-keymap
/usr/sbin/install-menu
/usr/sbin/install-sgmlcatalog
/usr/sbin/invoke-rc.d
/usr/sbin/ip6tables-apply
/usr/sbin/iptables-apply
/usr/sbin/iptraf
/usr/sbin/ispell-autobuildhash
/usr/sbin/ldattach
/usr/sbin/libgvc5-config-update
/usr/sbin/locale-gen
/usr/sbin/logrotate
/usr/sbin/lpadmin
/usr/sbin/lpc
/usr/sbin/lpinfo
/usr/sbin/lpmove
/usr/sbin/luksformat
/usr/sbin/make-ssl-cert
/usr/sbin/minissdpd
/usr/sbin/mkinitramfs
/usr/sbin/mklost+found
/usr/sbin/modem-manager
/usr/sbin/mono-server2-admin
/usr/sbin/mono-server2-update
/usr/sbin/mysqld
/usr/sbin/mysqlmanager
/usr/sbin/NetworkManager
/usr/sbin/newusers
/usr/sbin/nologin
/usr/sbin/ntpdate
/usr/sbin/ntpdate-debian
/usr/sbin/ownership
/usr/sbin/pam-auth-update
/usr/sbin/pam_getenv
/usr/sbin/paperconfig
/usr/sbin/pcscd
/usr/sbin/pm-hibernate
/usr/sbin/pm-powersave
/usr/sbin/pm-suspend
/usr/sbin/pm-suspend-hybrid
/usr/sbin/pmt-ehd
/usr/sbin/pmvarrun
/usr/sbin/pppd
/usr/sbin/pppdump
/usr/sbin/pppoe-discovery
/usr/sbin/pppstats
/usr/sbin/pwck
/usr/sbin/pwconv
/usr/sbin/pwunconv
/usr/sbin/readprofile
/usr/sbin/rebuild-security-providers
/usr/sbin/reject
/usr/sbin/remove-default-ispell
/usr/sbin/remove-default-wordlist
/usr/sbin/rmail
/usr/sbin/rmt
/usr/sbin/rmt-tar
/usr/sbin/rotatelogs
/usr/sbin/rpcinfo
/usr/sbin/rsmtp
/usr/sbin/rtcwake
/usr/sbin/rtkitctl
/usr/sbin/rtmpgw
/usr/sbin/rtmpsrv
/usr/sbin/rtmpsuck
/usr/sbin/runq
/usr/sbin/rvnamed
/usr/sbin/safe_finger
/usr/sbin/select-default-ispell
/usr/sbin/select-default-wordlist
/usr/sbin/sendmail
/usr/sbin/service
/usr/sbin/setvesablank
/usr/sbin/split-logfile
/usr/sbin/squid3
/usr/sbin/sshd
/usr/sbin/synaptic
/usr/sbin/sync-available
/usr/sbin/syslog2eximlog
/usr/sbin/tcpd
/usr/sbin/tcpdchk
/usr/sbin/tcpdmatch
/usr/sbin/tcpdump
/usr/sbin/tcptraceroute
/usr/sbin/tcptraceroute.db
/usr/sbin/traceroute
/usr/sbin/try-from
/usr/sbin/tunelp
/usr/sbin/umount.hal
/usr/sbin/update-alternatives
/usr/sbin/update-apt-xapian-index
/usr/sbin/update-binfmts
/usr/sbin/update-bootsystem-insserv
/usr/sbin/update-ca-certificates
/usr/sbin/update-catalog
/usr/sbin/update-ccache-symlinks
/usr/sbin/update-cracklib
/usr/sbin/update-default-aspell
/usr/sbin/update-default-ispell
/usr/sbin/update-default-wordlist
/usr/sbin/update-dictcommon-aspell
/usr/sbin/update-dictcommon-hunspell
/usr/sbin/update-exim4.conf
/usr/sbin/update-exim4.conf.template
/usr/sbin/update-exim4defaults
/usr/sbin/update-flashplugin-nonfree
/usr/sbin/update-fmtutil
/usr/sbin/update-fonts-alias
/usr/sbin/update-fonts-dir
/usr/sbin/update-fonts-scale
/usr/sbin/update-gsfontmap
/usr/sbin/update-inetd
/usr/sbin/update-info-dir
/usr/sbin/update-initramfs
/usr/sbin/update-java-alternatives
/usr/sbin/update-language
/usr/sbin/update-language-dat
/usr/sbin/update-language-def
/usr/sbin/update-locale
/usr/sbin/update-mime
/usr/sbin/update-passwd
/usr/sbin/update-python-modules
/usr/sbin/update-rc.d
/usr/sbin/update-rc.d-insserv
/usr/sbin/update-texmf
/usr/sbin/update-texmf-config
/usr/sbin/update-updmap
/usr/sbin/update-usbids
/usr/sbin/update-xmlcatalog
/usr/sbin/upgrade-from-grub-legacy
/usr/sbin/usb_modeswitch
/usr/sbin/usb_modeswitch_dispatcher
/usr/sbin/usbmuxd
/usr/sbin/useradd
/usr/sbin/userdel
/usr/sbin/usermod
/usr/sbin/validlocale
/usr/sbin/vbetool
/usr/sbin/vcstime
/usr/sbin/vigr
/usr/sbin/vipw
/usr/sbin/visudo
/usr/sbin/vpddecode
/usr/sbin/zic
$ 4.2.20 15 515---> ~

grep . global regular expression print

commandline session

$ 4.2.20 1 501---> ls /usr/sbin/ | grep kernel
$ 4.2.20 2 502---> ls /usr/sbin/ | grep ker
cracklib-packer
cracklib-unpacker
$ 4.2.20 3 503---> ls /usr/sbin/ | grep linux
$ 4.2.20 4 504---> ls /usr/sbin/ | grep lin
update-ccache-symlinks
$ 4.2.20 5 505---> ls /usr/sbin/ | grep li
cracklib-check
cracklib-format
cracklib-packer
cracklib-unpacker
create-cracklib-dict
gnome-menus-blacklist
libgvc5-config-update
remove-default-wordlist
select-default-wordlist
split-logfile
update-ccache-symlinks
update-cracklib
update-default-wordlist
update-fonts-alias
validlocale
$ 4.2.20 6 506--->


$ 4.2.20 6 506---> ls /usr/sbin/ | grep -cv li
261
$ 4.2.20 7 507---> ls /usr/sbin/ | grep -c li
15
$ 4.2.20 8 508--->

(java) bubble sort testing… 0.00001 Ver — 6 No.'s Related

$ 4.2.20 4 504---> time java BubbleSort

real	0m0.254s
user	0m0.160s
sys	0m0.068s
$ 4.2.20 5 505---> time java BubbleSort

real	0m0.208s
user	0m0.152s
sys	0m0.036s
$ 4.2.20 6 506---> time java BubbleSort

real	0m0.209s
user	0m0.124s
sys	0m0.064s
$ 4.2.20 7 507---> time java BubbleSort

real	0m0.210s
user	0m0.144s
sys	0m0.044s
$ 4.2.20 8 508---> time java BubbleSort

real	0m0.254s
user	0m0.148s
sys	0m0.084s
$ 4.2.20 9 509---> time java BubbleSort

real	0m0.253s
user	0m0.180s
sys	0m0.056s
$ 4.2.20 10 510---> time java BubbleSort

real	0m0.226s
user	0m0.156s
sys	0m0.048s
$ 4.2.20 11 511--->

ant – a Java based make tool.

commandline session

$ 4.2.20 153 1003---> ant compile
Buildfile: /home/jeffrin/java/beautifulprograms/build.xml

copyjars:

compile:
    [javac] /home/jeffrin/java/beautifulprograms/build.xml:36: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 1 source file to /home/jeffrin/java/beautifulprograms/war/WEB-INF/classes

BUILD SUCCESSFUL
Total time: 6 seconds
$ 4.2.20 154 1004--->

bubble sort in java

commandline session

/*
        Java Bubble Sort Example
        This Java bubble sort example shows how to sort an array of int using bubble
        sort algorithm. Bubble sort is the simplest sorting algorithm.
*/

public class BubbleSort {

        public static void main(String[] args) {

                //create an int array we want to sort using bubble sort algorithm
                int intArray[] = new int[]{5,90,35,45,150,3};

                //print array before sorting using bubble sort algorithm
                System.out.println("Array Before Bubble Sort");
                for(int i=0; i < intArray.length; i++){
                        System.out.print(intArray[i] + " ");
                }

                //sort an array using bubble sort algorithm
                bubbleSort(intArray);

                System.out.println("");

                //print array after sorting using bubble sort algorithm
                System.out.println("Array After Bubble Sort");
                for(int i=0; i < intArray.length; i++){
                        System.out.print(intArray[i] + " ");
                }
System.out.print("n "); /* ahiliation@yahoo.co.in */

        }

        private static void bubbleSort(int[] intArray) {

                /*
                 * In bubble sort, we basically traverse the array from first
                 * to array_length - 1 position and compare the element with the next one.
                 * Element is swapped with the next element if the next element is greater.
                 *
                 * Bubble sort steps are as follows.
                 *
                 * 1. Compare array[0] & array[1]
                 * 2. If array[0] > array [1] swap it.
                 * 3. Compare array[1] & array[2]
                 * 4. If array[1] > array[2] swap it.
                 * ...
                 * 5. Compare array[n-1] & array[n]
                 * 6. if [n-1] > array[n] then swap it.
                 *
                 * After this step we will have largest element at the last index.
                 *
                 * Repeat the same steps for array[1] to array[n-1]
                 *
                 */

                int n = intArray.length;
                int temp = 0;

                for(int i=0; i < n; i++){
                        for(int j=1; j < (n-i); j++){

                                if(intArray[j-1] > intArray[j]){
                                        //swap the elements!
                                        temp = intArray[j-1];
                                        intArray[j-1] = intArray[j];
                                        intArray[j] = temp;
                                }

                        }
                }

        }
}

/*
Output of the Bubble Sort Example would be

Array Before Bubble Sort
5 90 35 45 150 3
Array After Bubble Sort
3 5 35 45 90 150

*/


$ 4.2.20 7 507---> javac BubbleSort.java
$ 4.2.20 8 508---> java BubbleSort
Array Before Bubble Sort
5 90 35 45 150 3
Array After Bubble Sort
3 5 35 45 90 150
 $ 4.2.20 9 509--->