≡ Menu

echo usage

I noticed that many shell scripts in /etc/init.d/ directory use the following syntax:

echo $"Usage $prog start|stop|reload|restart"

Why a double-quoted string preceded by a dollar sign ($"string") using the echo command under Linux / UNIX bash scripts?
[click to continue…]

How do I determine whether a variable called spath="/srv/www/cyberciti.biz/https" contains a substring called "cyberciti.biz"?
[click to continue…]

If var is defined AND NOT EMPTY, use var, otherwise set a default variable under Bash. For e.g. my script needs a parameter for output variable. It can be text or html. I set it as follows in my script

output=$1 # either text or html

However, sometime user forget to pass the parameter to my shell script and my enter logic fails. So how do I set default value to text, if no parameter passed?
[click to continue…]

How do I check if file is empty or not using bash or ksh shell script under UNIX / Linux / OS X / BSD operating systems?
[click to continue…]

Bash Shell Script Function Examples

How do I create a shell script function using Bash under UNIX / Linux operating systems?
[click to continue…]

Linux Bash Script Check File Existence

How do I check if a file called /tmp/foo.txt exists or not using a shell script under Linux operating systems?
[click to continue…]