swap
is not a filesystem, it's not mounted, it's activated or deactivated (see man swapon
). A mountpoint does not exist. In /etc/fstab
the mountpoint is specified as none
. Since swap
is not mounted, I'd not expect the swap partition to appear in the output of mount
or findmnt
.
mount | grep sdb
gives no output because the string sdb
does not appear in the mount
-output. Remember, /dev/sdb
is your swap, it is not mounted.
mount | grep sd?
gives no output because the string sd?
does not appear in your mount
-output. A drive named sd?
does not exist, as simple as that. If you want grep
to treat sd?
as an extended regex, you'd use mount | grep -E sd?
and your output wouldn't be empty but it probably wouldn't be what you expect since the meaning of the ?
is very different in regex and globbing.
mount | grep "/dev/sd"
is what gives you the output you desire here.
Some more details:
From info grep
chapter 2.4 'grep' programms:
’-G’
‘--basic-regexp’
Interpret patterns as basic regular expressions (BREs). This is
the default.
From info grep
chapter 3.6 Basic vs Extended Regular Expressions:
Basic vs Extended Regular Expressions
In basic regular expressions the meta-characters ?, +, {, |, (, and ) lose
their special meaning; instead use the backslashed versions
\?, \+, \{, \|, \(, and \).
Portable scripts should avoid the following constructs, as POSIX says
they produce undefined results:
...
• Basic regular expressions that use ‘\?’, ‘\+’, or ‘\|’.
...
But even when I use \?
it does not work as expected for me, mount | grep sd\?
still gives empty output which definitely shouldn't be the case. It only gives me expected output with the -E
-option, with or without the backslash. Probably this is a bug.