Re: Bash globbing files only?

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

 



So, as expected then, yes?
Yes, as expected.  But not what I understood the OP was trying to do.
Unless I'm mistaken, that syntax (ls [^.]*/) was used to assign the
directory names in the current working directory to a variable.
However that is not the output of that command. The output is the
directories and their contents.  Hence where much of my confusion
came.

Does it make sense now?

Yes, it finally clicked this morning around 5:00 am when I was
driving.  I now understand the reason for the */ part of the syntax.

Ultimately the OP's wishes would be best/most accurately met using the
find command from what I can gather.

dirs=`find -maxdepth 1 -type d \! -regex "^\.$"`
(the \! -regex "^.$" to eliminate the . directory)
files=`find -maxdepth 1 -type f`

Or to remove the path name (./) to have only the file names (or
directory names), I would use:
files=`find -maxdepth 1 -type f -printf "%f "`
resulting in a space delimited output.

Jacques B.

[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux