LinuxCommandLibrary

shopt

TLDR

List all shell options with their status

$ shopt
copy
Enable a shell option
$ shopt -s [optname]
copy
Disable a shell option
$ shopt -u [optname]
copy
Check if an option is set (quiet mode)
$ shopt -q [optname] && echo "enabled"
copy
Enable extended globbing
$ shopt -s extglob
copy
Enable case-insensitive globbing
$ shopt -s nocaseglob
copy
Include dotfiles in glob patterns
$ shopt -s dotglob
copy
Print options in reusable format
$ shopt -p
copy

SYNOPSIS

shopt [-pqsu] [-o] [optname ...]

DESCRIPTION

shopt is a Bash builtin that enables or disables shell options for the current session. These options modify shell behavior including globbing, history handling, directory navigation, and command completion.
Without arguments, shopt lists all options and their current status. Use -s to enable and -u to disable specific options. The -q flag tests options silently, setting exit status 0 if enabled, 1 if disabled.
Options set with shopt persist only for the current session. Add shopt commands to ~/.bashrc for permanent configuration.

PARAMETERS

-p

Print shell options in a format reusable as input
-q
Quiet mode; suppress output, return status only
-s
Set (enable) the specified options
-u
Unset (disable) the specified options
-o
Restrict to options also settable with set -o

COMMON OPTIONS

cdspell

Auto-correct minor spelling errors in cd arguments
dotglob
Include files starting with . in glob patterns
extglob
Enable extended pattern matching operators
globstar
Enable ** recursive directory matching
histappend
Append to history file instead of overwriting
nocaseglob
Case-insensitive filename globbing
nullglob
Empty glob patterns expand to nothing instead of themselves
expand_aliases
Enable alias expansion (default in interactive shells)

CAVEATS

shopt is Bash-specific and not available in other shells like zsh, dash, or ksh, which have their own option mechanisms. The -o flag provides compatibility with options from the set builtin.

HISTORY

shopt is a Bash builtin introduced in Bash 2.0 (1996) to provide a cleaner interface for shell options compared to the set builtin. It continues to be the primary method for configuring Bash behavior.

SEE ALSO

set(1), bash(1)

> TERMINAL_GEAR

Curated for the Linux community

nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

$129.95
KIWITATA 2X Classic SNES USB Controller for PC Gamings, Retro SNES Wired USB Game Emulator Controller for Windows XP 7 8 11 Mac Raspberry Pi

KIWITATA 2X Classic SNES USB Controller for PC Gamings, Retro SNES Wired USB Game Emulator Controller for Windows XP 7 8 11 Mac Raspberry Pi

$16.99
BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

$239.99
Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community

New Raspberry Pi 3 Model B+ Board Raspberry PI 3B+

New Raspberry Pi 3 Model B+ Board Raspberry PI 3B+

$54.00
GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

$739.99
Bmax Mini PC B2 Power Intel 5205U 8GB DDR4 256GB M.2 NVMe SSD ,HDMI 1.4&DP 1.2, USB3.2,4K Dual Display 2.4G/5G WiFi & BT5.0 Mini Desktop Computers /Office/Design

Bmax Mini PC B2 Power Intel 5205U 8GB DDR4 256GB M.2 NVMe SSD ,HDMI 1.4&DP 1.2, USB3.2,4K Dual Display 2.4G/5G WiFi & BT5.0 Mini Desktop Computers /Office/Design

$169.99