Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filename globbing Windows vs. Unix

Is something like this possible in the Windows standard shell using wildcards only?

$ ls -1 003[5,8]0
00350
00380
like image 408
lukuluku Avatar asked Jul 19 '12 08:07

lukuluku


People also ask

What is file Globbing in Linux?

The Bash shell feature that is used for matching or expanding specific types of patterns is called globbing. Globbing is mainly used to match filenames or searching for content in a file. Globbing uses wildcard characters to create the pattern.

What is file Globbing?

A glob is a term used to define patterns for matching file and directory names based on wildcards. Globbing is the act of defining one or more glob patterns, and yielding files from either inclusive or exclusive matches.

What does a question mark in a file Globe match?

In glob syntax, a question mark matches any one character.


2 Answers

Not in the standard windows command shell (cmd.exe). It understands only the ? and * wildcards; no regular expressions.

Do you have the option of installing Cygwin, Windows Powershell, or another enhanced shell?

like image 135
Simbilis Avatar answered Oct 09 '22 12:10

Simbilis


yes, you can. Not with a single command, but with a combination of FOR and IF. Try this to get you started...

setlocal enabledelayedexpansion
for %%a in (003?0) do (
  set fn=%%a
  set fnl=!fn:~3,1!
  if .!fnl!==.5 (
    echo !fn!
  )
  if .!fnl!==.8 (
    echo !fn!
  )
)
like image 2
PA. Avatar answered Oct 09 '22 11:10

PA.