Quantcast
Channel: Bash – Musings
Browsing index pages (14 articles)

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


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

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

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


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

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

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


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


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

First Letter Capitalization in Bash and Korn Shell

Bash does not have a built-in facility to first letter capitalize a string but Bash 4.0 and later has the necessary tools to do so as shown by the following example: #!/bin/bash Firstcap() {...

View Article

Bash and Korn Shell Let Keyword

Recently a colleague of mine recommended using the let keyword in shell scripts to perform arithmetic evaluation. That prompted me to write this post about the let keyword. Here is what the bash...

View Article

Shell Script: Print Hexadecimal Representation of String

This post discusses how to print out the numeric value of a character in the underlying codeset in a shell script.

View Article


Linux Shell Script to Download YouTube Videos

Here is a bash shell script which downloads a YouTube video and plays it using GNOME's Totem movie player which is based on the GStreamer open source multimedia framework.

View Article
Browsing index pages (14 articles)


Latest Images