Translate

Image of Operating System Concepts
Image of RHCE Red Hat Certified Engineer Linux Study Guide (Exam RH302) (Certification Press)
Image of XSLT 2.0 and XPath 2.0 Programmer's Reference (Programmer to Programmer)
Image of Beginning Google Maps API 3

Bash-like Customizable Prompt in Korn Shell

Bash has built-in support for extensive PS1 prompt customization using parameterless macros. As a result many people customize their shell prompts. There is no equivalent built-in support for PS1 customization in ksh93 but such support can easily be added using a discipline function. This post provides an example of such a PS1 discipline function. Add the following discipline function to your ~/.kshrc and ensure that ~/.kshrc is included in your ~/.profile shell startup script which, by the way, only gets executed at login if ksh93 is your default shell. function PS1.set { typeset prefix remaining=${.sh.value} var= n= k= set -A

Korn Shell Launcher for Windows Subsystem for Linux

According to Microsoft, the Windows Subsystem for Linux (WSL) is a new Windows 10 feature that is essentially a compatibility layer which enables you to run native Linux command-line tools and utilities directly on Windows 10, alongside your traditional Windows desktop applications. Currently a beta feature, it is scheduled to be officially released in the Windows 10 Anniversary Update which is due CY2016Q3. There is no support for Linux GUI-based or TUI-based tools, utilities or applications not is any planned. When WSL is enabled, a Canonical-created Ubuntu user-mode image (currently named trusty-server-cloudimg-amd64-root.tar.gz and based on Ubuntu 14.04 Long-Term Support) is

Zero Padding Brace Expansions in the Korn Shell

Both bash and zsh shells support leading zeros in ranges: $ echo {1..10} 1 2 3 4 5 6 7 8 9 10 $ echo {01..10} 01 02 03 04 05 06 07 08 09 10 $ echo {001..010} 001 002 003 004 005 006 007 008 009 010 $ From the bash manpage section on brace expansion: Supplied integers may be prefixed with 0 to force each term to have the same width. When either x or y begins with a zero, the shell attempts to force all generated terms to contain the same number of digits, zero-padding where

The Time Keyword in Bash

The word time is one of the bash shell reserved words. It is not a bash shell builtin. $ builtin time bash: builtin: time: not a shell builtin Bash does support the older Bourne shell keyword times as a builtin. This builtin prints out the user and system times used by the shell and its children. So where is the time reserved word used in the bash shell? It is primarily intended for printing pipeline timing statistics. From the current online bash documentation: The format for a pipeline is [time [-p]] [!] command1 [| command2 …] The output of each

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