Re: Bash globbing files only?

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

 



On 1/29/07, James Wilkinson <fedora@xxxxxxxxxxxxxxxxxx> wrote:
Daniel Qarras wrote:
> I want just the files from the current directory, not from any subdir.
> And I'd prefer some bash globbing if possible for performance/elegancy
> reasons :)


The closest I could come up with was using
ls -Ap -I "pattern"

That caused directories to have / at the end of them. So I figured I
could use -I to ignore any filename ending with /.  However after a
few unsuccessfull variations I realized that the / is only displayed
at the end of directories therefore not part of the name. Which means
you cannot use a pattern to eliminate names ending in / (because the
name doesn't end with /, rather / is simply displayed after a
directory name).  Piping to grep would do it of course.

The find command with maxdepth and for type f is your best bet in my opinion.

If you come up with a way to do it from within ls I'd be interested in it.

Now lsattr comes close as well in that it lists files, but also
symbolic links to a directory.  But that produces the attributes along
with the file names.

Like John, I can see no way on how to do it with ls alone from within
bash. Clearly John has a solution for you using another shell so you
could call upon that shell interpreter.  But I don't see zsh on my
default FC6 install.

Jacques B.

Jacques B.


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux