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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Not able to create any file name start with "-" hyphen in Solaris
# 1  
Old 06-12-2010
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
# 2  
Old 06-12-2010
Code:
touch -- -file.txt


Last edited by bartus11; 06-12-2010 at 06:20 AM.. Reason: previous was wrong
# 3  
Old 06-12-2010
Thank you, it's working fine.

But why we are giving the extra -- for creation of the -file.txt .
# 4  
Old 06-12-2010
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).
# 5  
Old 06-12-2010
Once again thanks for your detailed explanation.
# 6  
Old 06-12-2010
Hi.

An additional (but older) workaround is to use:
Code:
touch ./-x

and that has even worked just now with:
Code:
OS, ker|rel, machine: SunOS, 5.10, i86pc
GNU bash 3.00.16

Best wishes ... cheers, drl
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Howto auto boot SPARC | How to auto supply "start /SYS" and "start /SP/console" commands

When I power ON my T4-1, I got a prompt -> where I have to start /SYS and start /SP/console. How can I auto supply these two commands ? (3 Replies)
Discussion started by: z_haseeb
3 Replies

2. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

3. Solaris

Solaris 10 error "-sh: /tmp/outfile: cannot create"

Hello, Each time a user log on to host, they receive below error: -sh: /tmp/outfile: cannot create Example: $ ssh host user@host's password: Last login: Fri Dec 4 08:17:28 2015 from client.ref |-----------------------------------------------------------------| -sh:... (2 Replies)
Discussion started by: feroccimx
2 Replies

4. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

5. Solaris

Printer configuration Migration from Solaris 10 "LP" to Solaris 11 "CUPS"

Need to find a way to import an LP printers.conf file to CUPS. I have some new Solaris 11.1 boxes that need to have 300 printers added. (0 Replies)
Discussion started by: os2mac
0 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

To start printing a file at line " n" .

To start printing a file at line " n" . let n = 10 and FileName = f1 (3 Replies)
Discussion started by: shashwat2691
3 Replies

8. UNIX for Dummies Questions & Answers

start top command in "solaris mode"

Ever noticed that using the top command on a multiple cpu box can often give totally misleading answers, like 230%, when you think that 100% should be the max? Well, that's because top has a bizarre mode called "Irix mode" wherein if you have 4 cpus, the %CPU column of top can go up to 400%. I... (1 Reply)
Discussion started by: fabulous2
1 Replies

9. HP-UX

To give the "unzip" permissions & "create" file permissions

Hi, I am a Unix Admin. I have to give the permissions to a user for creating new file in a directory in HP-Ux 11.11 system since he cannot able to create a new file in the directory. Thanks in advance. Mike (3 Replies)
Discussion started by: Mike1234
3 Replies

10. Shell Programming and Scripting

catalina.sh : need combination from "start" and "run"

heya, can someone help me with following problem. i am not sure how far you know the catalina.sh script from tomcat. when i start my tomcat with "catalina.sh run" then the startup-process-output will be printed out on the console, but the tomcat process is started in current shell/session, so... (1 Reply)
Discussion started by: Filly
1 Replies
Login or Register to Ask a Question