Tag Archives: Solaris

Shell: test: argument expected

The following shell script might work just fine on many of the available shell interpreters but the same would fail with the ‘test: argument expected’ error if you try to execute it under sh on Solaris platform.


touch /tmp/i_exist
if [ -e /tmp/i_exist ]; then
  echo "file exists!"

So, what we are trying in the above script is to check if the given file exists using shell’s [condition].
As per Solaris test(1):

-e file — True if file exists. (Not available in sh.)

A simple solution to this issue is to use ‘-f’ instead. It checks for the existence of regular files and supposed to work on most of existing shell interpreters.