Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] How to cope with strange filenames in bash?



On Tue, Jul 03, 2007 at 04:53:06PM +0900, Josh Glover wrote:
> On 03/07/07, Michal Hajek <hajek1@example.com> wrote:
> 
> >a simple question:
> 
> deserves a simple answer. ;)
> 
> >how do I cope in bash with filenames containing "-" character (i.e.
> >dash) ?
> 
> ls -- <fn>

This is the correct, and simplest answer. But there are ways to cope
with filenames starting with "-" even without using "--". One way is to
specify the path (.).

$ echo -n > -
$ ls -l -- -
-rw-r--r-- 1 tappel tappel 0 Jul  3 11:12 -
$ ls -l ./-
-rw-r--r-- 1 tappel tappel 0 Jul  3 11:12 ./-

Incidentally, you cannot create a file named "-" with touch without
specifying the path. And specifying the path works with all those
programs that do not honour "--".

-- 
Tapio Peltonen <tappel@example.com>


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links