Monday 15 March 2010

shell - How can I get a long listing of text files containing "foo" followed by two digits? -



shell - How can I get a long listing of text files containing "foo" followed by two digits? -

using metacharacters, need perform long listing of files name contains string foo followed 2 digits, followed .txt. foo**.txt not work, obviously. can't figure out how it.

use valid shell globbing character class

to find substring anywhere in filename bar-foo12-baz.txt, need wilcard before , after match. can utilize character class in pattern match limited range of characters. example, in bash:

# explicit character classes. ls -l *foo[0-9][0-9]*.txt # posix character classes. ls -l *foo[[:digit:]][[:digit:]]*.txt see also filename expansion pattern matching

shell unix ls metacharacters

No comments:

Post a Comment