I think you want to use a feature of the shell, not of ls
. I use bash, so I checked for what you want in man bash
. Search for "^EXPANSION", (by first pressing '/'). Excerpt:
EXPANSION
Expansion is performed on the command line after it has been split into words. There are seven kinds of expansion
performed: brace expansion, tilde expansion, parameter and variable expansion, command substitution, arithmetic
expansion, word splitting, and pathname expansion.
︙
... < snip > ...
︙
Pathname Expansion
After word splitting, unless the -f option has been set, bash scans each word for the characters *
, ?
, and [
. If one
of these characters appears, then the word is regarded as a pattern, and replaced with an alphabetically sorted list
of file names matching the pattern. …
I've recently started excluding files based on their first letter, with a command like:
$ ls ./[^t]*
This would match anything that doesn't start with the letter t
. If you add more characters between the brackets, then you exclude files starting with those letters too.
Looking for a link, and I've a good one! See Pattern Matching. From there, this would work for your case:
$ ls -lrt ./!(temp_log.*)
This requires that the extglob
shell option is enabled
using the shopt
builtin (shopt -s extglob
), as stated by Gilles.
ls --hide='temp_log.$$'
should work. You could/should also extend this with wildcards, depending which part of the whole termtemp_log.$$
is. – erch Jul 23 '13 at 17:21