I want to use an argument in the function I created in my .profile file.
I want to ask for input if no argument is given, otherwise set a variable to $1.
When I check $1 to see if it is empty, I get the following error:
sh[7]: 1: Parameter not set.
From the following line:
if [ ! -n "$1" ]; then
I'm using sh not bash.
EDIT: Ok, here is the wholefirst line of code until the end of the if statmentstatement:
HOST=`hostname`
cd /opt/dirpath
ll *.sto
if [ !x"$1" -n= "$1"x ]; then
# Ask for input
echo "File: \c"; read outFile
else
outFile=$1
fi
I'm editing someone else's code to work with or without arguments.