commandline session $cat bash.txt hack hacker $cat < bash.txt hack hacker $wc < bash.txt 2 2 12 $wc -l yab.txt $cat yab.txt hello $wc < yab.txt 1 1 6 $
Category Archives: Uncategorized
Bash . set -o noclobber . environment manipulation
commandline session $set -o noclobber $ls a.out a.out $ls > a.out bash: a.out: cannot overwrite existing file $ $set +o noclobber $ $ls > a.out $rm a.out $
tput Query Terminfo Database
commandline session $tput cup 3 4 $tput cup 4 3 $tput cols 140 $tput lines 39 $tput setb 4 $tput setb ` > ^C > ^C $^C $tput setb 0 $ $tput setb 1 $ $
Grouping Output from several commands
commandline session $cd autotest/ $ls autotest cyclictest ${ ls ; pwd ; cd cyclictest ; ls ; pwd } > /tmp/all.out > ^C ${ ls ; pwd ; cd cyclictest ; ls ; pwd ; } > /tmp/all.out $cat /tmp/all.out autotest cyclictest /home/jeffrin/autotest client.DEBUG /home/jeffrin/autotest/cyclictest $
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 …
Bash . number of script arguments
commandline session $. var 1 2 3 4 4 $. var 1 2 3 4 3 3 3 7 $cat var Name=Jeffrin Age=36 echo $# $. var 0 $. var . 1 $. var $ 1 $. var ? 5 $. var ? 5 $. var 1 2 2 $. var ? 5 $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: …