1833839 Members
2544 Online
110063 Solutions
New Discussion

Re: ls command

 
Donna Powell
Advisor

ls command

I need some HP-UX help with listing a file with meatacharaters at the beginning of the file name. The file looks like this:

-EE-FILENAME

when I try and run a simple ls command the OS interpets the -E as an option and will not list the file. Even if I put the filename in double quotes I still can't get the OS to recognize the file as a file and not an option. In AIX I can use the # on files like this. What can I use for HPUX?
7 REPLIES 7
Jdamian
Respected Contributor

Re: ls command

Type the following

ls -- -EE-FILENAME
A. Clay Stephenson
Acclaimed Contributor

Re: ls command

Because ls uses the getopts convention, you can terminate the search for additional "-" options by using "--".

e.g.
ls -l -- -EE-FILENAME
the -l will be recognized and honored, "--" tells ls no more options so that everything after is a filename.
If it ain't broke, I can fix that.
Chris Wilshaw
Honored Contributor

Re: ls command

You need to tell the command that anything that follows is not an option to the command.

Do this using --

eg:

ls -- -EE-FILENAME
melvyn burnard
Honored Contributor

Re: ls command

use the esacpe or \ character as in:
ls \-EE-FILENAME
The \ escapes the special meaning of the next character immeidately following it.
My house is the bank's, my money the wife's, But my opinions belong to me, not HP!
Kenneth Platz
Esteemed Contributor

Re: ls command

You can use "ls -b" to output the nonprinting and/or metacharacters in octal, and you should be able to use the backslash key along with the appropriate octal notation to reference the file.
I think, therefore I am... I think!
Donna Powell
Advisor

Re: ls command

Thank you all for your replys. They were are great suggestions to resolve my problem. Thank you so much
Todd McDaniel_1
Honored Contributor

Re: ls command

one more thing that is not widely used...

If you use the ./ in front of the filename it will allow you to rm or mv it...

mv ./-EE--filename /tmp/
cp ./-EE--filename EE-filename


Also, great for use in scripts where you want to make sure you refer to a file in your current directory and not one similarly named in your $PATH!
Unix, the other white meat.