OT: Regex question

Keary Suska yellowdog-general@lists.terrasoftsolutions.com
Sat May 4 11:14:01 2002


on 5/4/02 10:32 AM, valites@geneseo.edu purportedly said:

> 
>> Just to clarify, the above example would fail for because of the -l option
>> passed to ls. You want just the file names, not the additional info that a
>> long listing provides.
>> 
>> $ tar cvf output_file.tar `ls -da [^A-Z]* | grep -v /path/to/file/to/skip`
>> 
> 
> 
> Without the -l, aren't the basenames of filenames outputted from the
> backtick interpreted as being in the cwd?

They are, whether or not -l is used. -l is simply specifying the long
listing display, but whether the file names contain path information depends
solely on the path specified to ls. hence:
    $ ls -da [^A-Z]*
contains no path info, so matching file names in the cwd will be shown
without path info, regardless of the use of -l. However,
    $ ls -da /path/to/[^A-Z]*
will return a listing with each file name as /path/to/file_name, also,
regardless of the use of -l.

The problem with using -l is that you effectively get something like:
    $ tar cfv file.tar -rw-r--r-- 1 user group   1704874 Jan 19 17:32 file

which will choke tar, especially since it will look at the permissions as
options, and will look for files with names "1", "user", "group", etc.

Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"