Not able to create any file name start with "-" hyphen in Solaris

Hi All,

I am not able to create any file name start with "-" hyphen. Any logical issue with these types of files creation in Solaris.

==============================
bash-3.00$ touch -file.txt
touch: illegal option -- i
usage: touch [-acm] [-r ref_file] file...
touch [-acm] [MMDDhhmm[yy]] file...
touch [-acm] [-t [[CC]YY]MMDDhhmm[.SS]] file...
bash-3.00$ uname -a
SunOS P427XODSAP 5.10 Generic_125100-05 sun4u sparc SUNW,Sun-Fire-V490

Regards
Hanumantha Rao

touch -- -file.txt

Thank you, it's working fine.

But why we are giving the extra -- for creation of the -file.txt .

Becouse words or letters that are prefixed with "-" are considered to be options passed to command. "--" means that there are no more options to be passed and what comes after that is considered as argument (in this case a filename).

Once again thanks for your detailed explanation.

Hi.

An additional (but older) workaround is to use:

touch ./-x

and that has even worked just now with:

OS, ker|rel, machine: SunOS, 5.10, i86pc
GNU bash 3.00.16

Best wishes ... cheers, drl