Shell String Concatenation

Many people are unaware that string concatenation using the += syntax is fully supported in modern versions of both the Bash and Korn shells Here is a simple example which demonstrates the syntax: str=”Hello” $ str+=” ” $ str+=”World” $ echo $str Hello World $ If you use this syntax with “numbers”, you end up with a string that looks like a number but is not a number. $ a=2 $ a+=4 $ echo $a $ 24

Shell Script to List ACPI tables

ACPI (Advanced Configuration and Power Interface) defines platform-independent interfaces for hardware discovery, configuration, power management and monitoring, and these tables contain lots of useful information for low-level programmers such as myself. Here is a short shell script which I clobbered together a few days ago to list out the ACPI tables on a system together with a short description of each table where possible. #!/bin/bash # # Author: Finnbarr P. Murphy # Date: January 2015 # Purpose: List ACPI tables # License: BSD # TMP1=$(mktemp -u -p /var/tmp/ acpiXXXXXX) TMP2=$(mktemp -u -p /var/tmp/ acpiXXXXXX) TMP3=$(mktemp -u -p /var/tmp/ acpiXXXXXX) cat

Differences in Variable Scope in Shell Functions

Ksh93 and bash have subtly different scopes for variables defined in shell functions as the following example shows: # POSIX function syntax testme2() { printf “Function testme2 invokedn” var21=testme21 typeset var22=testme22 } function testme1 { printf “Function testme1 invokedn” var11=testme11 typeset var12=testme12 } testme1 echo “VAR11=$var11” echo “VAR12=$var12” Here is the output when run under ksh93: Function testme1 invoked VAR11=testme11 VAR12= Function testme2 invoked VAR21=testme21 VAR22=testme22 and here is the output when run under bash: Function testme1 invoked VAR11=testme11 VAR12= Function testme2 invoked VAR21=testme21 VAR22= Note the different output for var22! Ksh93 has lexical scoping. A variable is normally global

Accessing Cisco Secure ACS 5.X Internals

Cisco Secure Access Control System is based on CentOS. This post will show you how to access the Bash shell as root, and explores the underlying filesystem layout and utilities which make up this product..

Fedora 18 Supports 256 Color Terminals

You may not be aware of it but currently Linux terminal emulators such as xterm only supports 8 colors while those on Apple’s OS X support 256 colors. Now, beginning with Fedora 18, Fedora will also support 256 colors via the xterm-256color terminfo database entry. To see how many colors a terminal supports: $ echo $TERM xterm-256color $ tput colors 256 I have never liked the default colors produced by the –color color option to ls and other utilities and, as a result, have normally removed such aliases from my bash startup scripts. Having 32 times more colors available gives