Operations 2 min read

Listing Directories 00‑12 Using Bash extglob Pattern

This article explains how to list directory names ranging from 00 to 12 in a log folder by enabling Bash's extglob option and applying a regular‑expression‑style pattern with the ls command.

Qunar Tech Salon
Qunar Tech Salon
Qunar Tech Salon
Listing Directories 00‑12 Using Bash extglob Pattern

A log directory contains subfolders named 00, 01, 02 … 31, and the task is to display only the folders for the first twelve days (00‑12) using a pattern on the file names.

shopt -s extglob
ls -al +(0[0-9]|1[0-3])

Explanation

Works in Bash only.

Typical shell globbing uses simple wildcard semantics, not full regular‑expression semantics.

Enabling extglob switches globbing to extended pattern (regex‑like) semantics.

The syntax +(pattern) matches one or more occurrences of the given pattern.

Author: He Weiping, Qunar Travel Division, senior search and database researcher, former Yahoo China search engineer, with extensive experience in search, distributed systems, databases, and cluster design.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ShellBashregexextglobfile-listing
Qunar Tech Salon
Written by

Qunar Tech Salon

Qunar Tech Salon is a learning and exchange platform for Qunar engineers and industry peers. We share cutting-edge technology trends and topics, providing a free platform for mid-to-senior technical professionals to exchange and learn.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.