Quantcast
Channel: Bash – Musings
Browsing latest articles
Browse All 14 View Live

Bash Hash Builtin

The Bash shell hash builtin maintains a hash cache (table) containing the full pathname of previously executed commands that are on your PATH environmental variable. If the command is in the hash...

View Article



Implementing strstr in Korn Shell

Neither Bash or the Korn Shell 93 (ksh93) provide a C-like strstr builtin. Here is a simple implementation of a strstr function in ksh93. The strstr function finds the first occurrence of s2 in s1. If...

View Article

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"...

View Article

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:...

View Article

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...

View Article


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 $...

View Article

Korn Shell Launcher for Windows Subsystem for Linux

In this post, I show you how to create a Korn Shell launcher for the new Windows Subsystem for Linux.

View Article

Bash-like Customizable Prompt in Korn Shell

Bash has built-in support for extensive PS1 prompt customization and as a result many people customize their shell prompts. There is no equivalent built-in support for PS1 customization in ksh93 but...

View Article


Printing Bash or Korn Shell Script Arguments

This post discusses various issues, workarounds and solutions to printing details of arguments (AKA positional parameters) passed to shell scripts via the command line upon invocation of the shell...

View Article


Bash Printf %T Option

This post discusses and demonstrates how to use the printf %T date functionality available in the Bash shell since version 4.2.

View Article
Browsing latest articles
Browse All 14 View Live




Latest Images