Home » Articles » Technical » System Administrator » Shell Scripts

Category: Shell Scripts

Shell Script function to manage execution error

A simple shell script to manage execution error and display a meaningful message to the user This function was designed for Korn Shell *ksh93* and should be POSIX Compliant. Please message me if you have suggestion to make it better. ### Simple function to display separator character on the size of terminal width f_print_separator () …

Read more

Shell Script function get password

How to securely get a password from a user in a POSIX Compliant Shell Script.   There is 2 ways to create a function to securely get password in a shell script. 1. ksh93 and bash compliant: read -rsp "contextual message" variable 2. POSIX Compliant: printf %s "contextual message"; stty -echo; read passwd; stty echo; …

Read more

Korn Shell – Variables Quick Reference

Korn Shell – Variables Quick Reference Typeset type and attribute options -A Create an associative array. -En Represent the variable internally as a double-precision floating-point number; improves the efficiency of floating-point arithmetic. If n is given, it is the number of significant figures to use in output. Large numbers print in scientific notation: [-]d.ddde±dd. Smaller …

Read more

Why is printf better than echo in Shell Scripting?

Basically, it’s a portability (and reliability) issue. Initially, echo didn’t accept any option and didn’t expand anything. All it was doing was outputting its arguments separated by a space character and terminated by a newline character. Now, someone thought it would be nice if we could do things like echo "\n\t" to output newline or …

Read more