![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how can i replace "(", "\" "+" in a file | mail2sant | Shell Programming and Scripting | 3 | 04-22-2008 08:10 PM |
| Development Releases: Linux Mint 4.0 Beta "Fluxbox", 4.0 Alpha "Debian" | iBot | UNIX and Linux RSS News | 0 | 01-04-2008 12:00 PM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-19-2007 10:52 PM |
| "sed" to check file size & echo " " to destination file | jockey007 | Shell Programming and Scripting | 6 | 11-13-2007 06:00 PM |
| No utpmx entry: you must exec "login" from lowest level "shell" | peterpan | UNIX for Dummies Questions & Answers | 0 | 01-18-2006 01:15 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to cat a file , name starts with "-" ?
I have a question - beginning user, just learning unix.
I have a file that name starts with a hypen -, such as a name like : -myfile (yes, I know shold not start files names like this, but this is the question I have to figure out, and its driving me nuts) I know that this hyphen is like a special character.. right ? So how do I cat or more this file to see its contents when it is named like this ? I've tried commenting the hyphen, such as : cat '-'myfile and I have tried cat \-myfile with no success. Advice appreciated. ::email removed:: Last edited by oombera; 02-19-2004 at 02:34 PM. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Quote:
/ EOF |
|
#3
|
||||
|
||||
|
Hey,
You need to let cat know that you aren't trying to feed it a flag. This can be done by using -- $ cat -- \-filename Cheers, Keith Last edited by kduffin; 11-17-2003 at 07:28 PM. |
|
#4
|
|||
|
|||
|
Found answer, thanks for help
Thanks for the help on this. I finally found ( or stumbled across) the answer by looking in the "man rm" , where it says that following the rm command with the "--" means it treats what follows that as a filename, allowing the filename to start with the hyphen.
Is the hyphen a "special character " ? I don't see it listed as such in the lists of special characters.....??? |
|
#5
|
||||
|
||||
|
Not a special character per say, but it is what is used to identify option flags at the CLI. -- is used to denote an end of all option flags. Congrats on having found the answer yourself before hand. I have always found great satisfaction in problem solving and creative thinking. UNIX and other such appendages provide a good playground for such activities.
Cheers, Keith Last edited by kduffin; 11-17-2003 at 07:28 PM. |
|
#6
|
||||
|
||||
|
Hi,
You can do cat ./-myfile as well. |
|
#7
|
|||
|
|||
|
hehe i guess no one caught onto my hint...
|
|||
| Google The UNIX and Linux Forums |