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?
ow do I check if a file is empty or not using bash or ksh shell script under a UNIX / Linux / macOS / OS X / BSD family of operating systems? How do I check if a file is empty in Bash?
How do I skip bash for loop if certain condition is satisfied under UNIX / Linux / BSD / OS X?
ow can you test if a file is writable under UNIX / Linux bash shell scripting and programming language?
Q. How do I use bash for loop under Linux operating systems?
How do I check if a file called /tmp/foo.txt exists or not using a shell script under Linux operating systems?