JFTR: If you need that, you can write
ls *' book'
which would list all files (without “shopt -s dotglob”, only those whose
name is not starting with a dot) whose name ends in “ book”. You can also
use double-quotes:
$ ls *" book"
My book
This has the advantage of easy use of apostrophes –
$ ls *"'"*"books"
Frank's books
Thomas' books
parmenides' books
– and the possibility of safe parameter expansion:
$ suffix='favorite books'
$ ls *"'"*"$suffix"
Frank's favorite books
Thomas' favorite books
parmenides' favorite books
The disadvantage is that you may need to write more escape sequences then,
for example if a filename contains a backslash. But you can switch back to
single quotes for that part:
$ suffix='favorite books'
$ ls *"'"*"$suffix"' on \\shares\for-all'
Frank's favorite books on \\shares\for-all
Thomas' favorite books on \\shares\for-all
parmenides' favorite books on \\shares\for-all
(Not that I would generally recommend having such filenames. But the
possibility exists and one should know how to deal with it.)
In any case, ls(1) is to be preferred over “echo” here because it lists one
filename per line (provided that it does not contains newline). A possible
exception is a for–in loop.
--
PointedEars
Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.