Bash globbing files only?
Jacques B.
jjrboucher at gmail.com
Tue Jan 30 14:35:28 UTC 2007
> 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.
More information about the users
mailing list